• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to convert Char array to two dimensional string

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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];
}
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
prazannag Kumar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
thisismy
firstprogram

Since converting char[] to String[][] is all you want, so I'm move this question to Beginning Java forum...
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember there is no such thing as a 2D array. A String[][] is not a 2D array, but an array of arrays of Strings.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic