retour à la ligne en java

frol

Membre confirmé
14 Janvier 2005
59
0
35
bonjour je dois faire un retour à la ligne dans une variable en java
j'ai essayé
string mavar ="test1
test2";

évidemment ça ne marche pas

Pourriez vous m'indique comment faire

Merci Frol
 
Salut,

tu peux écrire :

String var = "ligne1\nligne2";

ou alors, pour avoir un retour à la ligne portable :

String NEWLINE = System.getProperty("line.separator");
String var = "ligne1" + NEWLINE + "ligne2";