i hAD produced a 2-dimensionatogether selection in Java and also ns wtogether searching for a way to Publish it the end ~ above ns console so that i could confirm that ns ingredient ns wtogether makinns wtogether correct. I discovered some password virtual the percreated this job because that me, yet i hADVERTISEMENT a Inquiry around what a certain bit of ns password meant.

You are watching: What does /n mean in java

int n = 10;int<><> network = new int;//some password dealing with populating Gridvoi would PrintGrid() { for (inns i = 0; ns What doens " " do? ns make the efforts browsing top top Google, however Because it"ns such a little little bit that code i couldn"t uncover much.


*

Its ins a brand-new line

escape Sequencesto escape sequence Description s Inserns a tAbdominal in the message in ~ thins point. Inserns a backVoid in ns text in ~ this point. Inserns a newline in the message at thins point. Insert a carriEra return in the message in ~ this point.f Inserns a formfeed in ns text in ~ thins point." Inserns a single quote personality in the message at this point." Insert a dual quote character in the text in ~ this point.\ Insert a backslash character in the text at this point.http://docs.oracle.com/javase/tutorial/java/data/characters.html


*

Thins means inserns a newheat in ns message at thins point.

simply example

System.out.println("hello world");Output:

helloworld

*

(as every http://java.sun.com/...ex/Pattern.html)

ns backcut personality ("") serves come introduce escaped constructs, as defined in ns table above, and to quote personalities that otherwise would certainly be understood together unescaped constructs. Thus ns expressitop top \ matchens a single backcut and { matches a lefns brace.

other Instances the intake :

\ the backcut character s the tAbdominal muscle character ("u0009") ns newline (line feed) character ("u000A") the carriage-rerevolve personality ("u000D")f ns form-feed character ("u000C")a ns alerns (bell) personality ("u0007")e ns to escape character ("u001B")cx ns manage personality equivalent come x


that means a new heat is printed.

together a next Note tright here is no need to write the added line . There is one constructed in inbuilt attribute there.

println() //printns the content in brand-new lineFind Out more from docs



ins a escape character for string that is reput with the brand-new heat object. Writing in a string that printns the end will certainly Publish the end a new line insteADVERTISEMENT that the

Java escape Characters


In the specific case of the code instance native the Initial question, ns

System.out.print(" ");is tright here come relocate to a brand-new line between incrementinns i.

so the initially Publish statement prints every one of ns facets the Grid<0>. As soon as the innerMost because that loop has actually completed, ns " " gets printed and then all of ns facets the Grid<1> to be printed on the following line, and also this ins repeated till you have a 10x10 network of the aspects of ns 2-dimensional array, Grid.

See more: Champion Auto Sales Machesney Park Il Linois Car Dealer, Champion Motor Cars In Machesney Park, Il


is include a brand-new line.

please Keep in mind java has method System.out.println("write message here");

notification the difference:

Code:

System.out.println("message 1");System.out.println("message 2");Output:

text 1text 2Code:

System.out.print("text 1");System.out.print("message 2");Output:

message 1message 2

not the price you're lookinns for? browser other inquiries tagged java or ask her own question.


site architecture / logo © 2021 ridge Exreadjust Inc; user contributions licensed under cc by-sa. Rev2021.10.29.40598


your privacy

by click “accept all cookies”, friend agree stack Exadjust can keep cookies top top your device and also disclose indevelopment in accorrun with ours Cookie Policy.