by Dinesh Thakur Category: Data Type

Type casting is the process of "casting"(Casting mean ‘conversion’ of value to another type) of value to one type to another type of variable.

Here is the Java Example for Type Casting:

class  TypeCasting

            public  static  void  main  (String  args[ ] )
                        int   i=65;
                        byte b;
                        double   d;
                        char    c;
                        short   s;
                        float     f;
                        b=  (byte) i;
                        System.out.println("Byte  of  Integer  "+i+  "  is  "+b);
                        f= (float)i;
                        System.out.println ("Float  of  Integer  "+i+  "  is  "+f);
                        c=(char) i;
                        System.out.println("Char  of  Integer  "+i+  "  is  "+c);
                        System.out.println("Double of  Float    "+f+  "  is  "+d);
                        System.out.println("Byte  of  Float  "+f+  "  is  "+b);
                        System.out.println("Int  of  Float  "+f+  "  is  "+i);
                        System.out.println("Double  of  Char  "+c+  "  is  "+d);
                        System.out.println("Byte  of  Char  "+c+  "  is  "+b);
                        System.out.println("Int  of  Char  "+c+  " is " +i);

Type Casting in Java

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.