Results 1 to 7 of 7

Thread: \n command

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    5

    \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

  2. #2
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    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";
        }
        
    }

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    5

    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!

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    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

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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");
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: \n command

    As requested by Adam,


  7. #7

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    5

    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
  •  



Click Here to Expand Forum to Full Width