Type Promotion
/**
* typepromotion
*/
import java.util.*;
public class typepromotion {
public static void main(String[] args) {
// Type Promotion in Expressions
// 1 . Java automatically promotes each byte, short, or char operand to int
// when evaluating an expression.
// 2. If one operand is long, float or double the whole expression is
// promoted to long, float, or double respectively.
byte b = 4;
char c='a';
short s = 512;
int i = 1000;
float f = 3.14f;
double d = 99.999;
double result= (f*b )+(i%c)-(d*s);
}
}
Comments
Post a Comment