public class T5 { public static void main(String[] args) { int a = new Integer("0"); short b = (short)65536; long c = 0000000000000000000L; byte d = (byte)256; char e = (char) 48; String f = new String("0");
Java是严格区分大小写的。 原始类型 封装类 boolean Boolean char Character byte Byte short Short int Integer long Long float Float double Double 引用类型和原始类型的行为完全不同,并且它们具有不同的语义。例如,假定一个方法中有两个局部变量,一个变量为 int 原始类型,另一个变量是对一个 Integer 对象的对象引用:int i = 5; // 原始类型 Integer j = new Integer(9); // 对象引用
我是说数字后面跟L或l这种写法我只到 long i=10L; long i=10l; 这两种写法是对的 其他基本类型怎么写? 是不是不区分大小写?
int a = new Integer("0"); 不能这样转换 在java中 长的不能转为短的类型
大写的是class 小写的是基本类型
public Text{ public static void main(String []args) {long i=10L; long j=10l; System.out.println("i="+i+" "+"j="+j); } }
Long 表示类
long 才是基本类型
public static void main(String[] args) {
int a = new Integer("0");
short b = (short)65536;
long c = 0000000000000000000L;
byte d = (byte)256;
char e = (char) 48;
String f = new String("0");
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
System.out.println(e);
System.out.println(f);
}
}随便写写,希望能对你有用~~
原始类型 封装类
boolean Boolean
char Character
byte Byte
short Short
int Integer
long Long
float Float
double Double
引用类型和原始类型的行为完全不同,并且它们具有不同的语义。例如,假定一个方法中有两个局部变量,一个变量为 int 原始类型,另一个变量是对一个 Integer 对象的对象引用:int i = 5; // 原始类型
Integer j = new Integer(9); // 对象引用
long i=10L;
long i=10l;
这两种写法是对的
其他基本类型怎么写?
是不是不区分大小写?
不能这样转换
在java中
长的不能转为短的类型
小写的是基本类型
public static void main(String []args)
{long i=10L;
long j=10l;
System.out.println("i="+i+" "+"j="+j);
}
}
long l2 = 10l;
float f1 = 1e+5f;
float f2 = 2e-9F;
double d1 = 1d;
double d2 = 1D;
long i = 10l;
long l = 10L;都是一样的