Casting means assigning a value of one type to a variable of another type.
public class CastTest{
public static void main(String[ ]args){
long bigValue = 99L;
int smallValue = (int)bigValue; // Casting
System.out.println(smallValue);
smallValue = 50;
bigValue = smallValue; // Auto Casting
System.out.println(bigValue);
}
}
Type Casting in Java:
Assigning a value of one type to a variable of another type is known as Type Casting.
Example :-
int x = 10;
byte y = (byte)x;
public class CastTest{
public static void main(String[ ]args){
long bigValue = 99L;
int smallValue = (int)bigValue; // Casting
System.out.println(smallValue);
smallValue = 50;
bigValue = smallValue; // Auto Casting
System.out.println(bigValue);
}
}
Type Casting in Java:
Assigning a value of one type to a variable of another type is known as Type Casting.
Example :-
int x = 10;
byte y = (byte)x;
I appreciate you sharing this article. Really thank you! Much obliged.
ReplyDeleteThis is one awesome blog article. Much thanks again.
sap online training
software online training
sap sd online training
hadoop online training
sap-crm-online-training