TopBottom

Followers

Followers



Click on more
SUBSCRIBE



VIDEO

Announcement: wanna exchange links? contact me at ravikrak@yahoo.com

Type conversion in Java

Posted by Ravi Kumar at Saturday, March 14, 2009
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

The type conversion in java of two types.
a)Automatic type conversion
b)Casting

Automatic type conversion: When one type of data is assigned to another type of variable an automatic type conversion will take place.
Conditions 1)The two types are compatible 2)The destination type is larger than the source type.
Ex:
int x=10;
byte y=2;
x=y; byte to int automatic conversion.


Casting: It is used to perform conversion between incompatible types.
Syntax: (Target_type)value
Target type specifies the desired type of convert the specified value to.
Ex:
Int i=257;
Byte b;
B=(byte)i; //now b value is 1.

Share |

Labels:

0 comments:

Post a Comment