Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

breaking the string  RSS feed

 
amal shah
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
i have a String as:

String s="abcdefghijklmnopqrs";

now i want the o/p as

abc
defghijk
lm
nop
qrs

the basic idea here is to break up the string
am not understanding how am i suppose to go about solving it..



help appreciated

cheers
 
Ajay Singh
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how are trying to break the string? I don't see you are breaking based on number of characters?
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your answer is SubString
Check this link to know how it works with String value.
SubString Demo
 
Guru dhaasan
Ranch Hand
Posts: 126
Java Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can also use string.charAt() function as the logic to mention how many characters to be selected.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!