Results 1 to 2 of 2
Thread: I don't understand the output,
- 12-10-2009, 07:51 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 4
- Rep Power
- 0
I don't understand the output,
Produces this:Java Code:while(fromFile.hasNextLine()) { //goto next Node here while(fromFile.hasNext()){ //create nested linked list here input=fromFile.next(); System.out.print(input + " "); //Will print everything twice. try { hold = Integer.parseInt(input); System.out.print(hold + " "); adjMatrix[i][hold-1]=1; } catch (NumberFormatException e) { } } System.out.println(); i++; }
Which makes complete sense, however if this is my code:Java Code:2 2 1 1 2 2 4 4 3 3 2 2 2 2 5 5 7 7 3 3 6 6 4 4 7 7 8 8
My results are this:Java Code:while(fromFile.hasNextLine()) { //goto next Node here while(fromFile.hasNext()){ //create nested linked list here input=fromFile.next(); try { hold = Integer.parseInt(input); System.out.print(hold + " "); adjMatrix[i][hold-1]=1; } catch (NumberFormatException e) { } } System.out.println(); i++; }
What I want is:Java Code:2 1 2 4 3 2 2 5 7 3 6 4 7 8
If I remove the try catch statement as well as only print the String, I have no issues, but I need to convert the String to an integer for matrix values.Java Code:2 1 2 4 3 2 2 5 7 3 6 4 7 8
Any help would be great, thank you.Last edited by TIMBERings; 12-10-2009 at 07:55 AM. Reason: Coding edits
- 12-10-2009, 08:03 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Similar Threads
-
cant understand what this means
By hasysf in forum New To JavaReplies: 19Last Post: 09-05-2009, 04:27 PM -
Java, output string, getting correct output? HELP!
By computerboyo in forum New To JavaReplies: 2Last Post: 02-25-2009, 11:44 PM -
I don´t understand
By Manikyr in forum New To JavaReplies: 6Last Post: 02-22-2009, 11:22 PM -
New: Want to understand Drawing...
By diRisig in forum New To JavaReplies: 1Last Post: 02-05-2008, 08:13 AM -
i don understand this error
By Deon in forum New To JavaReplies: 4Last Post: 01-12-2008, 10:03 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks