标签:[] oat 2.3 des 报错 long lse 变量 desktop
class Demo
{
public static void main(String[] args)
{
byte a = 3;
System.out.print(a);
}
}
byte -128到 +128
class Demo
{
public static void main(String[] args)
{
byte a = 300;//这里会报错
System.out.print(a);
}
}
超出+128 损失精度
C:\Users\admin\Desktop\d1>javac 123.java
123.java:5: 错误: 不兼容的类型: 从int转换到byte可能会有损失
byte a = 300;
^
1 个错误
class Demo
{
public static void main(String[] args)
{
byte a = 30;
short b = 4000;
int x = 12;
long l = 12345678;
/*
float f = 2.3;
C:\Users\admin\Desktop\d1>javac 123.java
123.java:11: 错误: 不兼容的类型: 从double转换到float可能会有损失
float f = 2.3;
^
1 个错误
*/
float f = 2.3f;
double d = 3.4;
char ch = ‘a‘;
boolean bl = true;
bl = false;
System.out.print(bl);
}
}
标签:[] oat 2.3 des 报错 long lse 变量 desktop
原文地址:https://www.cnblogs.com/150643com/p/10273242.html