`
leonzhx
  • 浏览: 798749 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论
文章列表
import java.util.concurrent.TimeUnit; class TestWork { volatile int i = 0; void f() throws InterruptedException { while (i == 0) wait(); System.out.println("Waken!"); } synchronized void g() { i = 1; notifyAll(); } } class Test { public static void m ...
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.Arrays; class Test { public static void main (String[] args) throws Exception { ByteArrayOutputS ...
import java.util.ArrayList; import java.util.Iterator; public class Test { public static void main(String[] args) throws Exception { ArrayList<String> a = new ArrayList<String>(); a.add("A"); a.add("B"); Iterator i = a.iterator(); i.next(); a. ...
import java.util.ArrayList; import java.util.Arrays; import java.util.ListIterator; public class Test { public static void main(String[] args) throws Exception { ArrayList<String> a = new ArrayList<String>(Arrays.asList("A B C" .split(" "))); ListIterat ...
import java.util.ArrayList; import java.util.Arrays; import java.util.ListIterator; public class Test { public static void main(String[] args) throws Exception { ArrayList<String> a = new ArrayList<String>( Arrays.asList("A B C D E F G H I J K".split(" " ...
public class Test { public static void main(String[] args) throws Exception { ArrayList<String> a = new ArrayList<String>(); ArrayList<String> b = new ArrayList<String>(); a.add("A"); a.add("A"); a.add("A"); a.add("B" ...
以下程序中不会编译出错的是: 1) import java.util.ArrayList; import java.util.List; class Test { static <T> T f(List<T> a, T b) { a.add(b); return a.get(0); } static void g() { ArrayList a = new ArrayList(); f(a, "KKKK"); } }   2) import java.u ...
以下程序中不会编译出错的是: 1) class Test<T> { Test(T item) { if (item instanceof T) System.out.println("Yes"); } }   2) class Test<T> { private T item = new T(); }   3) class Test<T> { private Class c = T.class; }   4)   class Test< ...
package mypackage; import java.util.Arrays; class Generic<T> { public T[] getArrays() { return (T[]) new Object[] { "1", "2" }; } } public class Test { public static void main(String[] args) { Generic<String> a = new Generic<String>( ...
import java.util.Arrays; class Generic<T> { public T[] getArrays() { return (T[]) new Object[] { "1", "2" }; } } public class Test { public static void main(String[] args) { Generic<Double> a = new Generic<Double>(); System.out.printl ...
import java.util.ArrayList; public class Test { public static void main(String[] args) { ArrayList<String> a = new ArrayList<String>(); a.add("A"); a.add("B"); ArrayList<String>[] b = new ArrayList<String>[] { a }; System.out.printl ...
class handler implements InvocationHandler { private ProxiedInterface p = null; handler(ProxiedInterface p) { this.p = p; } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { ((ProxiedInterface) proxy).g((Integer) args[0]); return met ...
class AnotherTest { public AnotherTest() { } public <T> ArrayList<T> f() { return new ArrayList<T>(); } public <T> ArrayList<T> f(ArrayList<T> a) { return a; } } public class Test { public static void main(String[] arg ...
class AnotherTest { private int i = 1; private final int j = 2; private int f() { return j; } } public class Test { public static void main(String[] args) throws Exception { AnotherTest a = new AnotherTest(); Field f1 = a.getClass().getDeclaredField("i" ...
class AnotherTest { public class inner { } } public class Test { public static void main(String[] args) { System.out.print(AnotherTest.inner.class.getConstructors().length); System.out.print(AnotherTest.class.getConstructors().length); System.out.print(Test.class.getCons ...
Global site tag (gtag.js) - Google Analytics