#How to do the same thing as .charAt(), but with String. ("string.At()"?

1 messages · Page 1 of 1 (latest)

gloomy ventureBOT
#

<@&987246399047479336> please have a look, thanks.

glass coral
#

did you at least try to do it with string?

stable halo
#

first place to look is always the javadocs

glass coral
#

...it's the exact same code

pliant creek
#

String str = "Leo";
System.out.print(str.charAt(1));

Output:
e

#

charAt also works the same way with strings

crimson jolt
#

substring?

pliant creek
#

StringBuilder sb = new String("Leo with a doubt");
String str = sb.substring(0,3);

and if you want a stringbuilder just plug that string in new StringBuilder object

sb = new StringBuilder(sb.substring(0,3));