1. 命名规范
标识符由字母、数字、下划线“_”、 “$”或者 “¥”组成,并且首字母不能是数字。
变量名不允许出现空格或非字母符号,比如+ -
变量名不能是java的关键字
String #name = "Jane Doe"; //Error
int $age = 24; //OK
Double _height = 123.5; //OK
double ~temp = 37.5; //Error
3. 搞清 x==4
if((x==4) && !b2)
4. 控制符
if((distance+1 != tail) ^ ((story*2)==distance))
z:
for(int x=0; x<3; x++){
for(int y=0; y<2; y++){
if(x == 1) break;
if(x==2 && y==1) break z;
o = o + x + y;
}
}
System.out.println(o);
8. false^false= false 和数学0^0不一样
if((distance+1 != tail) ^ ((story*2)==distance))
10. Arrays.binarySearch的用法,如果搜索到返回index,如果搜索不到返回 负号+最后一个index
int s2 = Arrays.binarySearch(colors, "orange");
13. String…相当于String[] 参数必须放在最后
public void go(String... y, int x)
14. 子类如果要构造,必须要显示调用含有参数的父类构造函数
public static void main(String...a){
public static void main(String... a){
public static void main(String[]... a){
18. 注意super(); this()等父类显示调用等问题
20 低耦合,高内聚
27 class Two extends One对foo()进行了重写
31. 具有相同变量,作用空间不同显示不同,和函数重写不一样。
public class Base{
public static final String FOO = "foo";
public static void main(String[] args){
Base b = new Base();
Sub s = new Sub();
System.out.print(Base.FOO);
System.out.print(Sub.FOO);
System.out.print(b.FOO);
System.out.print(s.FOO);
System.out.print(((Base)s).FOO);
}
}
class Sub extends Base{public static final String FOO = "bar";}
foobarfoobarfoo
35. 下面这种写法不加public可以,但构造函数必须写成this()
public class Blip {
String title;---默认打印为null
int value;
public Hello(int value){
this.value = value;
title = "Hello";
Hello();
36不懂
38 函数返回值如果是继承关系也不会报错。
class One{
public One foo(){return this;}
}
class Two extends One{
public One foo(){return this;}
}
39.除了构造函数final 不能够赋值
private final int id;
public void updateId(int newId){id = newId;}
41.
Integer x = 400;
Integer y = x;
//x == y false
StringBuilder sb1 = new StringBuilder("123");
StringBuilder sb2 = sb1; //sb1 == sb2 true 将sb1的地址引用给了sb2,就是说sb1和sb2在内存中指向同一个地址
47.背答案,不难,但又做错了