-1

I have done C++ in the past and to continue with a long line of code I would use the:

\

operator. My compiler does not seem to recognize that in Java (obviously). What command do I use for next line within the code itself, not the output.

Edit: example -

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!");

Error: 1 error found: File: H:\CISS 110\BarakGasPrice.java [line: 12] Error: String literal is not properly closed by a double-quote

4
  • 4
    Just write on the next line. Blanks are ignored by the compiler. Commented Feb 25, 2019 at 16:25
  • @ernest_k still does not work for some reason...I am using Drjava Commented Feb 25, 2019 at 16:27
  • @FaridB: The single line of code in the question does not produce the error in the question. So that doesn't really clarify. Commented Feb 25, 2019 at 16:32
  • If you are using eclipse format your code Ctrl+Shit+F in windows Commented Feb 25, 2019 at 16:42

1 Answer 1

1

Break the string at a sensible spot and concatenate the two strings together.

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!");
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.