Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Exception in thread "main" java.lang.NullPointerException
- at Test1.main(Test1.java:14)
- public class Test1 {
- public static void myMethod(int i)
- {
- System.out.println("calling @"+ i+"time");
- }
- public static void main(String arg [])
- {
- for(int i = 0;i<=999;i++)
- {
- Test1 obj[] = null;
- obj[i] = new Test1();
- obj[i].myMethod(i);
- }
- }
- }
- Test1 obj[] = new Test1[1000];
- for(int i = 0;i<=999;i++)
- {
- //Test1 obj[] = null; // <----------- don't want this here
- Test1 obj[] = new Test1[1000];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement