What are these '\n' and '\t'

Discussion in 'Mac Programming' started by larswik, Oct 6, 2006.

  1. larswik macrumors 68000

    Joined:
    Sep 8, 2006
    #1
    I hit page 200 in the Java for dummies book and when he talks about Switches the author start using code like this
    Code:
     details += "\tNew Car Scent, Plus...\n"; 
    He dosen't explaine it and it may not be important but it confuses me and I just wanted to understand it.

    thanks.

    -Lars
     
  2. peterparker macrumors regular

    peterparker

    Joined:
    Mar 12, 2005
    Location:
    Houston
  3. larswik thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #3
    Ahhh, but they are located within the quates " " 's. My understanding is that everything that is located between them is printed "Print this statement";

    -Lars
     
  4. Eidorian macrumors Penryn

    Eidorian

    Joined:
    Mar 23, 2005
    Location:
    Indianapolis
    #4
    '\' is an escape character. The following character(s) are treated differently then printed text.
     
  5. Heath macrumors regular

    Joined:
    Aug 19, 2005
    Location:
    Canada
    #5
    Yes, you are correct, everything in the quotes is printed. However there are things called 'escape sequences' these allow you to print characters you couldn't otherwise print in quotes. If you ponder a bit, how else could you print a double quote? Escape sequences are denoted by a \. So \n is the escape sequence for a new line and \t is the escape sequence for a tab. These are treated differently than normal text in the quotes. There are many escape sequences available your book probably covers them at some point, have a peek in the index.


    hehe 3 minutes!
     
  6. larswik thread starter macrumors 68000

    Joined:
    Sep 8, 2006

Share This Page