Java 一些容易出错小问题

List<String>[] list = new ArrayList[3];
//List<String>[] list = new ArrayList<String>[3];  语法错
if(a == 1) {
    //如果a为null会报异常 :shock: 
}

map.put("NULL", null);
String a = (String) map.get("NULL");
System.out.println(a);   //打印null

//Java Enum 枚举
	enum a {a,b,c};
	public static void main(String[] args) {
		a c = a.b;
		System.out.println(c + "\t" + c.ordinal());
	}
/**
*result :b	1
*/

public static Integer[] A = new Integer[] {B};
public static Integer B = 1;

public static void main(String[] args) {
		System.out.println(A[0]);
	}
/**
* result :0
**/

你可能感兴趣的:(java)