Results 1 to 4 of 4
- 05-10-2012, 08:50 PM #1
Member
- Join Date
- May 2012
- Posts
- 1
- Rep Power
- 0
Exception in thread "main" java.lang.NullPointerException
what is the problem with the code.....:(
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
class graph
{
public ArrayList<Integer[]> v=new ArrayList<Integer[]>();
public ArrayList<Integer[]> e=new ArrayList<Integer[]>();
}
public class main {
public static void main(String[] args) {
Integer vv[]=new Integer[2];
Integer ee[]=new Integer[3];
graph g[]=new graph[1000];
int i=-1;
String t="t";
String v="v";
String e="e";
FileInputStream fstream;
try {
fstream = new FileInputStream("graph1.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader b = new BufferedReader(new InputStreamReader(in));
String line;
try {
while ((line = b.readLine()) != null) {
StringTokenizer st = new StringTokenizer(line);
if(t.equals(st.nextToken()))
{
i++;
}
line = b.readLine();
System.out.println(line);
StringTokenizer st1 = new StringTokenizer(line);
if(v.equals(st1.nextToken()))
{
vv[0]=Integer.parseInt(st1.nextToken());
vv[1]=Integer.parseInt(st1.nextToken());
g[i].v.add(vv);
}
line = b.readLine();
StringTokenizer st2 = new StringTokenizer(line);
if(e.equals(st2.nextToken()))
{
ee[0]=Integer.parseInt(st2.nextToken());
ee[1]=Integer.parseInt(st2.nextToken());
ee[2]=Integer.parseInt(st2.nextToken());
g[i].e.add(ee);
}
}
} catch (IOException ex) {
Logger.getLogger(main.class.getName()).log(Level.S EVERE, null, ex);
}
} catch (FileNotFoundException ex) {
Logger.getLogger(main.class.getName()).log(Level.S EVERE, null, ex);
}
}}
Exception in thread "main" java.lang.NullPointerException
at main.main(main.java:64)
- 05-10-2012, 08:52 PM #2
Re: Exception in thread "main" java.lang.NullPointerException
You tell us. What is the stack trace? Have you stepped through this wit ha debugger or at least added some print statements to figure out when the flow of the program differs from what you expect it to do?
When posting code, please use the CODE tags.How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 05-10-2012, 09:27 PM #3
Re: Exception in thread "main" java.lang.NullPointerException
What variable on line 64 has a null value?Exception in thread "main" java.lang.NullPointerException
at main.main(main.java:64)If you don't understand my response, don't ignore it, ask a question.
- 05-10-2012, 09:34 PM #4
Similar Threads
-
Another Exception in thread "main" java.lang.NullPointerException problem
By wdh321 in forum New To JavaReplies: 6Last Post: 04-19-2012, 07:10 PM -
Got struck with this :- " Exception in thread "main" java.lang.NullPointerException"
By Vermont in forum New To JavaReplies: 5Last Post: 12-21-2011, 06:44 PM -
Exclamation Exception in thread "main" java.lang.NullPointerException
By Lorelai in forum New To JavaReplies: 5Last Post: 10-11-2011, 12:16 AM -
Exception in thread "main" java.lang.NullPointerException at LinkedList.main(Link
By kavitha_0821 in forum New To JavaReplies: 6Last Post: 07-16-2009, 03:30 PM -
Exception in thread "main" java.lang.NullPointerException at LinkedList.main(Link
By kavitha_0821 in forum New To JavaReplies: 1Last Post: 07-16-2009, 10:35 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks