62,614
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args)
{
int salary=1000_0000_000; //好像这样的数字是支持的是吧,但是报错
String test="hello"; //switch语句支持字符串了对吧,但是依然报错。
switch(test)
{
case "hello":System.out.println("hello");break;
default:System.out.println("error");break;
}
}
List<Integer> list={1,2,3};
Map<String,Integer> map={"hello":1,"hello1":2} 这样的......是我用法错了吗。
package csdn.programbbs_530;
public class NewFeature {
public static void main(String[] args) {
// 二进制字面值
int a = 0b01111_00000_11111_00000_10101_01010_10;
short b = (short) 0b01100_00000_11111_0;
byte c = (byte) 0B0000_0001;
System.out.println(a);
System.out.println(b);
System.out.println(c);
// 特性2:数字变量对下划线_的支持
int num = 1234_5678_9;
float num2 = 222_33F;
long num3 = 123_000_111L;
System.out.println(num);
System.out.println(num2);
System.out.println(num3);
// switch语句支持字符串
String test = "hello";
switch (test) {
case "hello":
System.out.println("hello");
break;
default:
System.out.println("error");
break;
}
}
}