Java:使 System.out.println() 参数跨越多行?

标签 java

我有以下信息:

System.out.println("Players take turns marking a square. Only squares not already marked can be picked. Once a player has marked three squares in a row, he or she wins! If all squares are marked and no three squares are the same, a tied game is declared. Have Fun!");

这是一条很长的消息,在我的屏幕上有条纹,我想把它分成几段,这样它就不会破坏我代码的设计流程。但是,当我按下回车键时,Java 不再将该行解释为字符串; Java认为它是一个单独的声明。如何让 Java 解释多行打印语句?

最佳答案

您正在寻找这样的东西吗?

String line = "Information and stuff" + 
          "More information and stuff " + 
          "Even more information and stuff";

System.out.println(line);

关于Java:使 System.out.println() 参数跨越多行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27408889/

相关文章:

java - Java 中的 DriverManager.getConnection 使用相对路径

java - SBT 包 JAR 文件,用于其他项目的 lib 文件夹中

java - 为什么反编译的构造函数字节码中存在 "this"的局部变量声明?

java - VS Code Java 调试器在某些代码行处卡住

禁用深度测试时,Java OpenGL 颜色 Material 变暗

java - 如何使用正则表达式验证破折号分隔值?

Java - 使用 copyOf 添加到数组

java - 静态概念

java - 将 Java 安全属性设置为 null

java - builder 模式