LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 732 users online 223811 members 1374 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
ss454
So if you're tired of the same old story, turn some p...
Mood: Plain
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
2 online / 85 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Adding Reply

Adding Reply
Archived Topic: It will not be bumped to the top of the forum.
Topic Help with Java
Membername   Not a member? Sign Up Free (takes 20 seconds)
Password   Forgotten your password?
Post

Font:   Size:   Color:

FAQ Keyword Search:
Post Options
Favorites Manager
Notify me of new replies to this topic by email
Notify me of new replies to this topic by private message
Original Post
Majo Posted at 2:05 pm on Sep. 12, 2008
I need to get I don't know how many different things to print out on different lines. How should I go about doing this? What would be the best way? I don't know if I should do it line by line like:

Code:
System.out.println("Hello");
System.out.println("Goodbye");

...or not because that's not really efficient, right? And we have to use the proper print function, as well, and I'm not sure if that's it. It'd also be nice if I could do it without stretching my page out like a mile long just to code it properly...

Replies
Majo Posted at 2:25 pm on Sep. 12, 2008
I don't know if that's "proper" or not, though.

Gah, I think I'll quit this one and email the professor to see what he wants, my back is killing me and I'm hungry anyways.

ampamp Posted at 2:23 pm on Sep. 12, 2008
The \n has to be inside the " marks. I don't see any reason to use them, when printing things out. I would just put them into indiviual println, to make it easier to read later.
Majo Posted at 2:23 pm on Sep. 12, 2008
Alright, I'll give that a go and see what happens when I try to compile it, thanks.
marshmellowman Posted at 2:20 pm on Sep. 12, 2008
The \n actually has to be within the text, no outside the quotes. So yours would be like:
Code:
System.out.println("Car make and model: Volkswagen Golf \n Expected Annual Mileage: " + mileage "\n Cost of a gallon of gas:" + gallon);
That's how I remember it anyway for C++, it might be different for Java, I'm not too sure.
Majo Posted at 2:15 pm on Sep. 12, 2008
It does but I'm not sure how to use it. I got two lines to print out separately but then it all fell apart. I need to do something like this:

Code:
System.out.println("Car make and model: Volkswagen Golf"\n "Expected Annual Mileage: " + mileage);

Assuming that's right, that's as far as I got before I couldn't figure out what to do next. Next, I need to add in something like:

Code:
("Cost of a gallon of gas: " + gallon)

But I don't know how to get that in there.

marshmellowman Posted at 2:08 pm on Sep. 12, 2008
Does the \n work like in C++? So you'd have:
Code:
System.out.println("Hello\nGoodbye");
All 6 previous replies displayed.