This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes converting String[][] to int[][] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "converting String[][] to int[][]" Watch "converting String[][] to int[][]" New topic
Author

converting String[][] to int[][]

Bill Brasskey
Ranch Hand

Joined: Jun 01, 2004
Posts: 47
Although I know this should be the simplest thing in the world, I'm having trouble converting a 2-dimensional String array to a 2-dimensional int primitive array.
int[][] intResult=Integer.parseInt(strResult[1][0]);
where should the brackets go on the right side of the expression...
i guess i'm just missing something here.
[ June 08, 2004: Message edited by: Bill Brasskey ]
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
HI Bill,

parseInt() can deal with only ONE string and spits out ONLY ONE int. So you would have to run a for loop to convert all objects in String[][] to int[][]...it can't be done by single API call.

Thanks
Maulin
Bill Brasskey
Ranch Hand

Joined: Jun 01, 2004
Posts: 47
is there any other way to do this w/out the for loop?
implicit conversion?
Lavern Matthew
Ranch Hand

Joined: Jun 05, 2004
Posts: 38
No. You need too:


Matthew Wilson<br />-http://valuelist.sourceforge.net
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
I'm afraid not: you're stuck with doing a nested "for" loop.

Why are you so concerned with this? A nested "for" loop only adds a few extra lines to your code.
 
 
subject: converting String[][] to int[][]
 
Similar Threads
Enhansed For Loop Please explain me
Array conversion Question from Dan's test
Question for Eugene re: push and pull in gui
Multi-dimensional arrays
multidimensional arrrays