Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

I get that a string cant span multiple lines but, what if your string is so long it goes to a new line?

+8 votes
What I mean by this is that say your string is as such

System.out.println("And what you are typing here just keeps going on and on for a really long time, say a really long time and does this where it spans onto another line here? Then what happens? Is this legal or do I need to create a new line once I hit the end of the typing space?");

Hopefully this helps...? Just curious if that is still legal as a string or if I needed to create a new line every time if I had something that was pretty long as an output print line.
asked Nov 16, 2015 in (Winter 15-16) by Kyle Cluver (100 points)

2 Answers

+2 votes
When you start programming in Eclipse, you will find that you can just keep typing and the line will get longer and longer... it won't "wrap" the text onto the next line!

Of course, you *can* do this, but it will be easier to read your code if you keep your lines of reasonable length...
answered Nov 17, 2015 by Forrest Stonedahl (3,438 points)
+1 vote

I looked this up and it looks like, while there technically is a character limit for a string, the limit is so high, that running out of memory is more likely than running out of characters. However, I tested a long string in Eclipse and (as Professor Stonedahl said) the output is difficult to read, since you need to scroll right to see all of it.

answered Nov 17, 2015 by Kristina Zimmerman (100 points)
...