• Post Reply Bookmark Topic Watch Topic
  • New Topic

android project  RSS feed

 
sabanathan kandeepan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am doing android project i got the output on android.

out put is:

company code:02
Payment and fees
0^0
Mtd
0^0^0^0



then i want spilt the below The Line:

0^0

0^0^0^0

Like
0
0
0
0
how i should spilt?

now i spilt like This
String s1 = "0^0";
String s2 = "0^0^0^0";
String[] s3 = s1.split("^");
String[] s4 = s2.split("^");
s3[0] = "0";
s3[1] = "0";
s4[0]="0";
s4[1]="0";
s4[2]="0";
s4[3]="0";
this way is Ok Or Not? Any Other way to spilt
please Reply soon

Thanks
Deepan
 
Prabaharan Gopalan
Ranch Hand
Posts: 66
Java Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are looking to split, then split() is one way to go. But when you split a string, the array will have the split characters already in them. so, you don't really have to explicitly assign "0" to each array item.

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sabanathan kandeepan wrote:now i spilt like This
String s1 = "0^0";
String s2 = "0^0^0^0";
String[] s3 = s1.split("^");
String[] s4 = s2.split("^");
s3[0] = "0";
s3[1] = "0";
s4[0]="0";
s4[1]="0";
s4[2]="0";
s4[3]="0";
this way is Ok Or Not? Any Other way to spilt


Hi sabanathan, Welcome to the Ranch!

Is this way OK? You tell us? does this do what you want it to do? If it does, then it is OK right? If it doesn't what does it do wrong? Why do you do the individual element assignments at the end (s3[0] = "0", etc...)? What worries do you have about this that you are not sure it is the correct way?

please Reply soon


Please BePatient (<- click). Something that would help is if you keep the conversation in the same thread. You started this other thread which you started on this subject, and sri ramvaithiyanathan was nice enough to provide some guidance. But when you abandon the thread and ask the same question in a new thread he doesn't see your response and can feel like you ignored his advice.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!