Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Bill Brasskey
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any other way to do this w/out the for loop?
implicit conversion?
 
Lavern Matthew
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. You need too:
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic