如何在Java中的多行源代码中分解字符串文字?

时间:2019-02-25 16:24:26

标签: java

我过去曾经做过C ++,为了继续编写一长段代码,我将使用:

\

操作员。我的编译器似乎无法识别Java(显然)。我在代码本身内的下一行 中使用什么命令,而不是输出中的 not

编辑:示例-

System.out.println("This code os too long to be put in one extremely long line of code so that is why I am asking this question\nThanks!");

错误: 找到1个错误: 文件:H:\ CISS 110 \ BarakGasPrice.java [行:12] 错误:字符串文字没有被双引号正确关闭

1 个答案:

答案 0 :(得分:1)

在适当的位置断开字符串,并将两个字符串连接在一起。

System.out.println("This code os too long to be put in one extremely long " +
                   "line of code so that is why I am asking this question\nThanks!");