| | |
2d array problem
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2007
Posts: 159
Reputation:
Solved Threads: 0
What is wrong with this code. when it do system.out.println(matrix[0][0] i should get 1 char i get the entire line.
Java Syntax (Toggle Plain Text)
int r =Integer.parseInt(line.substring(0)); int c = 10; String[][] matrix = new String[r][c]; while (line !=null) { for(int i =0; i< r; i++) { for (int j =0; j< c; j++) { line = br.readLine(); matrix[i][j] = line; } } } System.out.print(matrix[0][1]); }
Well, go figure: If you put the whole line in there, that's what you're going to get.
Java Syntax (Toggle Plain Text)
line = br.readLine(); matrix[i][j] = line;
![]() |
Similar Threads
- Need Help With two-dimensional array (VB.NET)
- Array problem (C++)
- class array problem! (C++)
- Array problem (C)
- C++ cout statement (C++)
- Large Array Problem (PHP)
- How do I create a program using an Array ? (C++)
Other Threads in the Java Forum
- Previous Thread: Can someone help me?
- Next Thread: I need help with a program that prints random lines from a file
| Thread Tools | Search this Thread |
Tag cloud for Java
actionlistener android api apple applet application apps arguments array arrays automation balls binary bluetooth card chat class classes client code component consumer database draw eclipse ee error event exception file fractal free game gameprogramming gis givemetehcodez graphics gui helpwithhomework html ide image input integer j2me j2seprojects java javaprojects jmf jni jpanel julia jvm linux list loop machine map method methods migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie nextline nls notdisplaying number oracle print problem program programming project recursion recursive scanner screen security server set size sms socket sort spamblocker sql sqlite string sun swing terminal test threads time tree trolltech windows






