Java的隐藏特征阅读后C#的隐藏特征我想知道,Java的一些隐藏特性是什么?
3 回答
交互式爱情
TA贡献1712条经验 获得超3个赞
温温酱
TA贡献1752条经验 获得超4个赞
public class Baz<T extends Foo & Bar> {}
public static <A, B extends Collection<A> & Comparable<B>>boolean foo(B b1, B b2, A a) { return (b1.compareTo(b2) == 0) || b1.contains(a) || b2.contains(a);}
精慕HU
TA贡献1845条经验 获得超8个赞
public class App { public App(String name) { System.out.println(name + "'s constructor called"); } static { System.out.println("static initializer called"); } { System.out.println("instance initializer called"); } static { System.out.println("static initializer2 called"); } { System.out.println("instance initializer2 called"); } public static void main( String[] args ) { new App("one"); new App("two"); }}
main
static initializer calledstatic initializer2 called instance initializer called instance initializer2 called one's constructor called instance initializer called instance initializer2 called two's constructor called
List<Integer> numbers = new ArrayList<Integer>(){{ add(1); add(2); }};Map<String,String> codes = new HashMap<String,String>(){{ put("1","one"); put("2","two");}};
添加回答
举报
0/150
提交
取消