示例代码:
public class Test {
public static void main(String []agrs){
int a,b;
a=10;
b=20;
short c=32768;//表示不了
int d = 32768;
System.out.println(c);
}
}
对于整型类型,Java各种整型能表示的最大范围如下:
byte:-128 ~ 127
short: -32768 ~ 32767
int: -2147483648 ~ 2147483647
long: -9223372036854775808 ~ 9223372036854775807
java 浮点数表示范围:
float -3.4*10(-38)次方到3.4*10(38) 不在范围内的,换类型。
示例代码:
public class Test {
public static void main(String []agrs){
int r=10;
float Pi=3.14f;
float S = Pi*r*r;
System.out.println(S);
}
}