samedi 28 mars 2015

Multiline strings concatenation in Java

I'm looking for some help. What is the easiest way to concatenate multiline strings in Java and print it after ?


For example : I've got two strings :



String turtle1 = " _\r\n .-./*)\r\n _/___\\/\r\n U U\r";
String turtle2 = " _\r\n .-./*)\r\n _/___\\/\r\n U U\r";


And I want to get this result in the Java Eclipse console :



_ _
.-./*) .-./*)
_/___\/ _/___\/
U U U U


I've already try some algorithms to divide my strings in differents parts and after re-concatenate it. But it was without success. I know there are StringBuffer class and StringBuilder class but after some research, I didn't found something that correspond to my need.


Thanks in advance for your help.


Aucun commentaire:

Enregistrer un commentaire