Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. Exception in thread "main" java.lang.NullPointerException
  2. at Test1.main(Test1.java:14)
  3.  
  4. public class Test1 {
  5. public static void myMethod(int i)
  6. {
  7. System.out.println("calling @"+ i+"time");
  8. }
  9. public static void main(String arg [])
  10. {
  11. for(int i = 0;i<=999;i++)
  12. {
  13. Test1 obj[] = null;
  14. obj[i] = new Test1();
  15. obj[i].myMethod(i);
  16.  
  17. }
  18. }
  19. }
  20.  
  21. Test1 obj[] = new Test1[1000];
  22.  
  23. for(int i = 0;i<=999;i++)
  24. {
  25. //Test1 obj[] = null; // <----------- don't want this here
  26.  
  27. Test1 obj[] = new Test1[1000];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement