java基础部分异常
错误: 找不到或无法加载主类 cn.tedu.hello.HelloWorld
原因: java.lang.ClassNotFoundException: cn.tedu.hello.HelloWorld
报上面错误,是无法正确编译java文件为class文件,可能class被误删除,可能eclipse项目管理bug,不自动编译
到项目目录中找到class文件,然后删除,重新编译
或者清除工程
The local variable a may not have been initialized
局部变量必须初始化
The final local variable b cannot be assigned. It must be blank and not using a compound assignment
final int b = 10;
b = 20;
局部变量,常量b,不能被再次赋值。
Dead code?
//与前面布尔结果为false,后面的代码已经不用判断
System.out.println(false && true); //false
逻辑短路与,前面已经是false结果就定了,此时后面是true还是false都不会影响结果,所以后面的代码是不会被执行的,性能更高
这个代码不会被执行
Cannot switch on a value of type long.
switch不支持long类型,太大了没有必要
Cannot switch on a value of type long. Only convertible int values, strings or enum 枚举 variables are permitted
switch的值不能是long类型,只能是可以转换为int的值(byte/short/char),后期又增加了string字符和enum枚举,enum是可以对应整数值的。
所以switch语句没有elseif灵活,elseif完全可以替代switch语句。