Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2010
    Posts
    16
    Rep Power
    0

    Default problem regarding giving value to string variable

    String str ="vijay\singh";
    it give error
    i want to make string which contain \ symbol but it give error

  2. #2
    Join Date
    Nov 2010
    Posts
    3
    Rep Power
    0

    Default

    you should escape the special char's for given string

    try the following string assignment,

    String str = "vijay\\singh";

    -Selvaraj

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    10,476
    Rep Power
    16

    Default

    '\' is the escape character.
    If you want just a '\' in the string you need to escape it...so:
    "vijay\\singh"

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Moderator
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    9,928
    Rep Power
    16

    Default

    Recommended reading: Lexical Structure

    db

Similar Threads

  1. String variable problem
    By gkoef in forum New To Java
    Replies: 4
    Last Post: 12-05-2010, 02:15 PM
  2. Convert variable name to string.
    By MHardeman25 in forum New To Java
    Replies: 9
    Last Post: 08-17-2010, 09:18 PM
  3. Object name by string variable?
    By zerkz in forum New To Java
    Replies: 4
    Last Post: 10-14-2009, 07:16 AM
  4. Replies: 1
    Last Post: 08-03-2007, 10:52 AM
  5. String Variable
    By Eric in forum Advanced Java
    Replies: 1
    Last Post: 06-06-2007, 04:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •