| | |
2d array problem
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2007
Posts: 156
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 |
911 actionlistener addressbook android api append applet application array arrays automation binary bluetooth character chat class classes client code component consumer csv database desktop draw eclipse error event exception fractal ftp game givemetehcodez graphics gui html ide image input integer j2me japplet java javaarraylist javaee javaprojects jmf jni jpanel julia linked linux list loop mac map method methods mobile netbeans newbie objects online oracle oriented panel print printf problem program programming project projects properties recursion replaydirector reporting researchinmotion robot rotatetext rsa scanner screen se server set size sms sort sql string swing template test threads time tree ubuntu windows working






