can someone explain how this code ouput's meme in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

26th May 2020, 6:21 PM
Ashutosh Singh
Ashutosh Singh - avatar
6 Answers
+ 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"
26th May 2020, 6:32 PM
zemiak
+ 4
pencil and paper 😁 did you find the substring?
26th May 2020, 6:26 PM
Oma Falk
Oma Falk - avatar
+ 3
Avinesh thanks for explaining
26th May 2020, 6:31 PM
Ashutosh Singh
Ashutosh Singh - avatar
+ 2
I realized that it was already explained, so I thought of removing my comment. Never mind you have received good answers.
26th May 2020, 6:35 PM
Avinesh
Avinesh - avatar
+ 1
char 3 is m char 5 is s So cheese.substring(3,5) is me str.concat(str) becomes me+me = meme
26th May 2020, 6:26 PM
Ore
Ore - avatar
+ 1
3 to 5 characters in cheese is "me" and "me" + "me" = meme
26th May 2020, 6:27 PM
farkhondeh