-
\n command
:wave: 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
-
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";
}
}
-
Re: \n command
http://i3.photobucket.com/albums/y83/RobPope/blueJ.jpg
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!
-
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?
-
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");
-
Re: \n command
-
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