|
-
Apr 6th, 2002, 02:11 PM
#1
array problem
I have a strig array of nine elements say
String temp[] = {"1", "2", "3", "4", "5", "6", "7", "8", "0"};
I want to break this in to a double dimensional array
like
int[][] puz = { { 1, 2, 3 }, { 4, 5, 6 }, { 7,8, 0 } };
I am getting
please help me
-
Apr 6th, 2002, 02:29 PM
#2
Dazed Member
So what you actualy want to do is convert the String array that you have into a two dimensional integer array?
Last edited by Dilenger4; Apr 6th, 2002 at 02:33 PM.
-
Apr 6th, 2002, 02:37 PM
#3
-
Apr 6th, 2002, 02:47 PM
#4
Dazed Member
What i probably would do is loop through the string array that you have and invoke the Integer.parseInt(String s) method.
-
Apr 10th, 2002, 03:55 PM
#5
Hyperactive Member
how's this? 
Code:
String temp[] = {"1", "2", "3", "4", "5", "6", "7", "8", "0"};
int [] [] td = new int [3] [3];
for (int i = 0; i < 3; i++)
for (int j = 0; j , 3; j++)
td [i] [j] = Integer.parseInt ( temp [j+(i*3)]);
that should do it, though there might be an error inside those for loops... oh well =D!
"There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein
If you are programming in Java use www.NetBeans.org
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|