java - Continuing Part Of String On New Line -


string noun1 = jtextfield1.gettext();         string noun2 = jtextfield1.gettext();         string noun3 = jtextfield1.gettext();          string verb1 = jtextfield1.gettext();         string verb2 = jtextfield1.gettext();         string verb3 = jtextfield1.gettext();          string adj1 = jtextfield1.gettext();         string adj2 = jtextfield1.gettext();         string adj3 = jtextfield1.gettext();          string story = "this story " + noun1;          jtextarea1.settext(story); 

i'm creating madlibs jframe , need find out how continue string on new line (i forgot) such story. need continue can add other sentences.

use line separator

string story = "this story a" + system.lineseparator() + noun1; 

or use \n new line

string story = "this story a\n" + noun1; 

also can use more system.out.println(...) commands when want print out.

system.out.println("this story a"); // print string inside , add linebreak afterwards system.out.println(noun1); // print value of noun1 variable 

all of them give following result:

this story "your story name" 

more information here: java string new line


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -