- A) Introduction
- Data Type Casting (Type Conversion)
byte TO | short | int | long | float | double | char | boolean |
short TO | byte | int | long | float | double | char | boolean |
int TO | byte | short | long | float | double | char | boolean |
float TO | byte | short | int | long | double | char | boolean |
double TO | byte | short | int | long | float | char | boolean |
char TO | byte | short | int | long | float | double | boolean |
boolean TO | byte | short | int | long | float | double | char |
- B) General
- Object Casting
sir, i got alot confusion in casting operations please provide me some notes and also here is one prog in which how should we do casting
public class main{
public static void main(String[] args){
Test t = new Test();
String s1 = new String();
String s2 = new String();
s1 =t.a;
s2 =t.b;
if (s1==s2){
System.out.println(“equal memory”);
}
else{
System.out.println(“diffent memory”);
}
}
}
in another java file ****************
public class Test{
int a= 20;
int b=20;
}
You can cast between compatibles only.