Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the output methods of java

Shulou Source: shulou.com Published: 2022-06-01 18:59:01 11月14日 Update

This article introduces the relevant knowledge of "java output methods". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

Usually we like to use System.out.println directly when outputting

But in fact Java also has some output, as shown in the video

System.out.println("Programmer")

This will change a line after the programmer is finished, because this println method calls the newLine() method again.

System.out.print("Learning Base")

This only output learning base camp, will not newline, you can see in the source code, only called the wirte method, no other use

System.out.printf("%s,%d","java",520);

This will format the output, replacing %s with java, %d with 520, and finally java 520.

String.format is the same as String.format, which we usually use.

//replace hello {520},{programmer learning base} with direct placeholder String formatOne = String.format("hello {%d},{%s}", 520, "programmer learning base"); System.out.println(formatOne); //with carry indentation, decimal { 100},{ 7.89} String formatTwo = String.format("{%4d},{.2f}",100,7.894652456f); System.out.println(formatTwo);

These two formatting processes eventually call the Formatter tool class.

"Java output methods what" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Tags: Output method learning big book base camp program programmer content actual more format knowledge practical ordinary successful learning next one line digits dilemma actually Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS MySQL Shulou Information Apple Xiaomi