如何在JAVA中使用转义序列

时间:2012-09-06 04:00:44

标签: java escaping

您好,我遇到了这个JAVA课程的问题。我知道这很简单,但它对我不起作用。

到目前为止我的代码是:

    public class ShowEscapeSequences {
    public static void main(String[] args) {
        System.out.print("I really like \n\t\"CIS355A\"Business Application Programming with Lab using JAVA\"");
    }//End of main
}

并给出了这个输出:

 I really like 


    "CIS355A"Business Application Programming with Lab using JAVA"

但我需要输出看起来像这样:

I really like

    CIS355A 
         "Business Application Programming with Lab using JAVA"

如何在不产生100个错误的情况下执行此操作?

2 个答案:

答案 0 :(得分:5)

你的字符串必须是

"I really like\n\n\tCIS355A \n\t\t \"Business Application Programming with Lab using JAVA\""

这是基于查看问题中的原始文本。

答案 1 :(得分:2)

System.out.print("I really like\n\n\tCIS355A \n\t\t\ "Business Application Programming with Lab using JAVA\"");