Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the output methods of java

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report