1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Little help with Java

Discussion in 'Programming & Webmastering' started by Jacko28, Nov 3, 2009.

  1. Jacko28 New Member

    Joined:
    Sep 23, 2008
    Messages:
    67 (0.03/day)
    Thanks Received:
    10
    I've began slowly learning java, however this morning I came to a halt, it's such a simple problem but I just can't get around it.

    The line of code involves using escape seqeuences to put illiegal characters into a print.out statement.

    "(\+\=\ \\)" ! help ! "{/&\is/\\}".

    Basically I have to put this into a line of code but I cant seem to get the escape sequences to work. From what I've read by using \ you can input the characters.

    Would it be ;

    \"(\\+\\=\\ \\\\)\" ! but ! \"{/&\is/\\\\}\". - To me this seems wrong and to my compiler it is wrong :laugh:

    Any help would be appreciated, many thanks

    Jacko28
     
  2. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    15,575 (6.19/day)
    Thanks Received:
    5,109
    Location:
    IA, USA
    Only quotes (because they start and end a string declaration) and backslashes (because they define the escape character) need to be escaped:
    string s = "\"(\\+\\=\\ \\\\)\" ! help ! \"{/&\\is/\\\\}\"";

    You forgot the extra backslash before "is"
     
    Jacko28 says thanks.
    Crunching for Team TPU
  3. Jacko28 New Member

    Joined:
    Sep 23, 2008
    Messages:
    67 (0.03/day)
    Thanks Received:
    10
    Thanks alot FordGT! :D
     

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page