Java 2 核心技术 卷1 基础知识 学习笔记
环境变量设置
Windows下 系统变量 jdk1.7@win7
1)java_home : jdk安装目录
2)classpath :
.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
3)Path :
%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin
cmd下查看是否配置成功
java -version
1 //将代码的编译错误输出到txt文件中 2 javac Test.java 2> error.txt 3 //新的错误输出文件会直接覆盖旧的
1 //运行applet 2 javac Test.java 3 appletviewer Test.html
0x1.0p-3 表示十进制 0.125 ,p表示指数
1 if(Double.isNaN(x)) // 检测x是不是一个数
Eclipse 中 文件自动添加注释: java-code style-code templates-comments
Eclipse 中 设置.java的Tab大小,java-code style-Formatter
浮点数除以0得到 无穷大 或 NaN
1 //舍入运算 2 double x = 9.9; 3 int nx = (int) Math.round(x); // x=10
1 for (int element : a) 2 System.out.println(element); // 输出数组a的每一个元素
1 GregorianCalendar calendar = new GregorianCalendar(year, month-1 ,day); //0表示一月
Eclipse source-Organize Imports // 具体导入
Eclipse Override/Implement Methods //生成父类的重写代码
1 public boolean equals(Object otherObject) { 2 // a quick test to see if the objects are identical 3 if (this == otherObject) return true; 4 5 // must return false if the explicit parameter is null 6 if (otherObject == null) return false; 7 8 // if the classes don't match, they can't be equal 9 if (getClass() != otherObject.getClass()) 10 return false; 11 12 // now we know otherObject is a non-null Employee 13 Employee other = (Employee) otherObject; 14 15 // test whether the fields have identical values 16 return name.equals(other.name) 17 && salary == other.salary 18 && hireDay.equals(other.hireDay); 19 }
1 public int hashCode() { 2 return 7 * name.hashCode() 3 + 11 * new Double(salary).hashCode() 4 + 13 * hireDay.hashCode(); 5 }
Error : 系统内部错误 或 资源耗尽
Exception:IOException 和 RuntimeException-由程序错误导致
ArrayIndexOutOfBoundsException-数组下标越界
NullPointException-变量为空

浙公网安备 33010602011771号