Results 1 to 4 of 4
Thread: return array problem
- 03-30-2010, 02:43 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 48
- Rep Power
- 0
return array problem
hi,
the method of my program suppose to return many values that i can call from main method and show in JTable. But it just showing the last one..
Java Code:public String[][] process(String searchName, String value){ .. FileReader reader; String[][] row=new String[][]{}; Map<String, File> names = new HashMap<String, File>(); try{ .. ... for (String found: names.keySet()) { .. .. [b]row =new String[][]{{found, file.getName(), Long.toString(file.length())}};[/b] } } catch(Exception e) {e.printStackTrace() } return row;
row+=found+"\t"+file.getName()+"\t"+file.length()+ "\n";
please help..what we are thinking, it might not be true
- 03-30-2010, 03:22 PM #2
You're overwriting your String[][] on every loop. You have to append:
Java Code:String[][] row= null; Map<String, File> names = new HashMap<String, File>(); try{ .. ... row = new String[names.keySet().size()][]; int i = 0; for (String found: names.keySet()) { .. .. row[i] =new String[]{found, file.getName(), Long.toString(file.length())}; i++; } } catch(Exception e) {e.printStackTrace() }
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 03-30-2010, 05:39 PM #3
Member
- Join Date
- Mar 2009
- Posts
- 48
- Rep Power
- 0
great.......
how can i appreciate you ?
really thanks a lot..........what we are thinking, it might not be true
- 03-30-2010, 06:08 PM #4Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
Similar Threads
-
How do i return a random String from an array?
By Grendel0 in forum New To JavaReplies: 9Last Post: 03-11-2010, 11:11 AM -
Problem with recurrsive return statement
By pachufir in forum New To JavaReplies: 3Last Post: 12-08-2009, 03:32 AM -
problem while using return statement
By shaluchandran in forum New To JavaReplies: 10Last Post: 12-12-2008, 07:29 PM -
return new variable -problem
By Hevonen in forum New To JavaReplies: 7Last Post: 12-08-2008, 07:07 AM -
return Set .toArray(); method as an array of integers
By maxim in forum New To JavaReplies: 2Last Post: 04-16-2008, 01:35 PM
Bookmarks