Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- /**
- *
- * @author Daniel Heinrich <dannynullzwo@gmail.com>
- */
- public class Test<E extends Number> {
- void test1()
- {
- try{
- E[] a = alloc(3);
- System.out.println("test1 win");
- }catch(Throwable t)
- {
- System.out.println("test1 fail");
- }
- }
- void test2()
- {
- try{
- E b = null;
- E[] a = alloc(3, b);
- System.out.println("test2 win");
- }catch(Throwable t)
- {
- System.out.println("test2 fail");
- }
- }
- public static <T> T[] alloc(int length, T... base) {
- return Arrays.copyOf(base, length);
- }
- public static void main(String[] args) {
- Test<Integer> a = new Test<>();
- a.test1();
- a.test2();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement