|
-
Dec 6th, 2005, 08:19 PM
#1
Thread Starter
New Member
\n command
Hi all, first post here!!
Anyways, I'm using BlueJ at uni *sighs* and I've been asked to turn n output into a toString method. Now, I have everything set up but I want it on multiple lines using the \n command, but BlueJ doesn't seem to support that by default. Where is the option to enable it?
TIA,
Rob
-
Dec 6th, 2005, 08:30 PM
#2
Fanatic Member
Re: \n command
Mean, something like?
Code:
public class Person {
private String firstName;
private String mi;
private String lastName;
public Person() {
}
public Person(String lastName, String firstName, String mi) {
this.lastName = lastName;
this.firstName = firstName;
this.mi = mi;
}
public String toString() {
return lastName + ",\n" + firstName + " " + mi + ".\n";
}
}
-
Dec 6th, 2005, 08:40 PM
#3
Thread Starter
New Member
Re: \n command

Exactly the same as what I was getting. The spec says to use toString to make the output user friendly.
I had it looking great with println!
-
Dec 7th, 2005, 08:19 AM
#4
Re: \n command
\n is not a command, its an escape character. Its not an option that can be turned on or off. I have never used BueJ, but I would suspect that since the entryfield that is displaying the data is single line, the tool itself is replacing the '\n' character with the actual string "\n" to show where a new line is.
Maybe?
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Dec 7th, 2005, 10:51 AM
#5
Re: \n command
Do you mean a newline object?
Code:
class Newline
{
String toString()
{
return "\n";
}
}
Its very simple to use. Pure genius if you ask me 
Code:
System.out.print("Line 1" + (new Newline()) + "Line 2");
-
Dec 7th, 2005, 10:57 AM
#6
Re: \n command
As requested by Adam,
-
Dec 7th, 2005, 06:49 PM
#7
Thread Starter
New Member
Re: \n command
^^ Thanks for that... NOT
anywhos, if it looks like BlueJ is being a stubborn pile of crap (wouldn't supprise me) then that's probably what it is.
I'll carry on with a bit of println.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|