简体   繁体   English

Java 文本编码

[英]Java Text Coding

Im trying to figure out is it possible to write a program where when the Text is written is there a way to have a new Line on it for example我想弄清楚是否有可能编写一个程序,例如,在写入文本时,是否有办法在其上添加新行

 the text would read       Hello World,
                           How may I help You

with out me having to make 2 strings it should just be one like String str = "Hello World, How may I help you";如果我不必制作 2 个字符串,它应该只是一个像 String str = "Hello World, How can I help you";

I feel like i might be over thinking the solution我觉得我可能想多了

Yes, you would use the newline character \\n .是的,您将使用换行符\\n The code would look like this:代码如下所示:

String str = "Hello World,\nHow may I help you";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM