Results 1 to 3 of 3
Thread: Nullpointer exception
- 12-17-2011, 11:56 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 6
- Rep Power
- 0
Nullpointer exception
hello,
It is giving NullpointerException, why?Java Code:import java.io.*; public class ArrayExample { static void add() { int k=9; int v=8; int r=k+v; System.out.println(r); } public static void main(String args[]) { ArrayExample ar[]=new ArrayExample[5]; ar[0].add(); ar[1].add(); ar[2].add(); ar[3].add(); ar[4].add(); } }Last edited by Eranga; 12-19-2011 at 04:34 AM. Reason: code tags added
- 12-17-2011, 12:11 PM #2
Banned
- Join Date
- Dec 2011
- Posts
- 143
- Rep Power
- 0
Re: Nullpointer exception
You are trying to access a field or method of an object which hasn't been set. From the compiler message, identify the line that is giving the exception and examine where each reference is being set. If you have any problems, post the line, with each reference and where you think you have set it.
- 12-19-2011, 04:36 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Re: Nullpointer exception
You sure that you ends with a NullPointerException?
Similar Threads
-
Nullpointer Exception with BufferedWriter?
By Solarsonic in forum New To JavaReplies: 3Last Post: 03-23-2011, 12:08 AM -
Nullpointer Exception???
By kipcorn91 in forum AWT / SwingReplies: 5Last Post: 10-28-2010, 11:19 PM -
NullPointer exception
By bdario1 in forum New To JavaReplies: 15Last Post: 03-17-2010, 04:44 AM -
nullpointer exception in jsp
By fiero in forum JavaServer Pages (JSP) and JSTLReplies: 6Last Post: 11-07-2008, 01:44 PM -
NullPointer Exception
By Preethi in forum New To JavaReplies: 8Last Post: 02-06-2008, 03:40 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks