Tuesday, 23 February 2016

Java Tutorial : Java wrapper class (Character)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=uHHb0bm0zVU&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java wrapper class (Character) 
Java Tutorial : Java wrapper class (Character) 
WrapperClassTest.java
public class WrapperClassTest
{

    public static void main(String[] args)
    {
        char ch = 'a';
        System.out.println("ch = " + ch);

        Character characterObj = new Character(ch);
        System.out.println("characterObj = " + characterObj);

        /*
         * If you pass a primitive char into a method that
         * expects an object, the compiler automatically
         * converts the char to a Character for you.This
         * feature is called autoboxing.
         */
        displayCharObj('c');

        /*
         * If you pass an object into a method that expects
         * an primitive char, the compiler automatically
         * converts the Character to a char for you.This
         * feature is called unboxing.
         */

        displayChar(new Character('z'));

    }

    public static void displayCharObj(Character characterObjParam)
    {
        System.out
                .println("characterObjParam = " + characterObjParam);
    }

    public static void displayChar(char chParam)
    {
        System.out.println("chParam = " + chParam);
    }
}
Output
ch = a
characterObj = a
characterObjParam = c
chParam = z
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/WrapperClassDemo_Character_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/WrapperClassDemo_Character_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/9880b82016e29094f797cfa7ceb03441b567b426/BasicJava/WrapperClassDemo_Character_App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge