How to convert Char array to two dimensional string
prazannag Kumar
Greenhorn
Joined: Feb 25, 2010
Posts: 12
posted
0
Hi,
I mess with converting the char array to two dimensional array in android. Anyone can clarify this issue ? Is it possible to do the conversion mentioned below ?
String[][] s = new String[3][3];
static char tmp[5] = "hello";
int r=1,c=1,j;
for( j=0;j<5;j++)
{
s[r][c].charAt(j)=tmp[j];
}
1. What does this question has to do with Android??
2. There are too many problems with your code. It will fail compilation at several locations. Even after correcting the errors, the logic doesn't seems right to me. I'm not even sure what exactly you are trying to achieve. How do you want to distribute the 1-D char array to a 2-D String array??
I ll explain my problem,
My Input is: "this is my first program"
then I have to split each word and to store on different string . It can be possible with 1D string array. suppose if i need to perform this on 2D string array,how to do? please let me know.
This message was edited 1 time. Last update was at by prazannag Kumar
prazannag Kumar wrote:suppose if i need to perform this on 2D string array,how to do?
This is exactly my question, how do you want to spread the words in a 2D string array?? You are saying that the input is "this is my first program", so now how do you want to spread it across a 2D string array?? Do you want 3 words in each row of the String array?? So basically the String array would become
this
is
my
first
program
Since converting char[] to String[][] is all you want, so I'm move this question to Beginning Java forum...
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 25060
posted
0
Remember there is no such thing as a 2D array. A String[][] is not a 2D array, but an array of arrays of Strings.
This message was edited 1 time. Last update was at by Campbell Ritchie
subject: How to convert Char array to two dimensional string