How to read spaces in a stringbuilder | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to read spaces in a stringbuilder

for example StringBuilder sb = new StringBuilder("Hello World); System.out .println(sb) gives me HelloWorld i want the space to appear so that it gives Hello World.

26th Feb 2020, 8:11 AM
Felix Munyaradzi Manamike
Felix Munyaradzi Manamike - avatar
4 Answers
+ 2
Felix Munyaradzi Manamike Space is space only, no reverting needed in that problem.. if(name. charAt(i) ==' ') //NO change, copy as it is, sb.append(name.charAt(i)) By the way, but you need also for after n character reciprocal.. For ex: z should be replaced by 'a'. So by that approach, you have to continue till z. So use ascii value representations.. For A ascii value is 65, so 65+25=90 is Z ascii value.. Hence those are serial numbers, you can find a logic for any char reciprocal...
26th Feb 2020, 9:31 AM
Jayakrishna 🇮🇳
+ 1
It will give- Hello World How come you are getting it without a space. Copy paste this line- StringBuilder sb = new StringBuilder("Hello World"); System.out.println(sb);
26th Feb 2020, 8:19 AM
Avinesh
Avinesh - avatar
0
Sorry i think i asked the question in a wrong manner i want to read spaces using a StringBuilder but its not working for the Secret Message Solution in Code Coach this is the code i created https://code.sololearn.com/cJBq1FVhBkoj/#java
26th Feb 2020, 9:02 AM
Felix Munyaradzi Manamike
Felix Munyaradzi Manamike - avatar