+ 2
can someone explain how this code ouput's meme in java?
String cheese = "parmesan"; String str = cheese.substring(3,5); str=str.concat(str); System.out.print(str); //output=meme
6 Respostas
+ 5
"parmesan".substring(3,5); // start at 3 stop at 5 -> "me"
012 34 567
par me san
str.concat(str); // str+str
"me"+"me" = "meme"
+ 4
pencil and paper 😁
did you find the substring?
+ 3
Avinesh thanks for explaining
+ 2
I realized that it was already explained, so I thought of removing my comment. Never mind you have received good answers.
+ 1
char 3 is m
char 5 is s
So cheese.substring(3,5) is me
str.concat(str) becomes me+me = meme
+ 1
3 to 5 characters in cheese is "me" and "me" + "me" = meme