1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Java-what if char is: '

  1. Oct 12, 2011 #1

    K29

    User Avatar

    If I want to work with a character literal, and it is the apostrophe, how do I do this?

    For example:

    Code (Text):

    if(Word.charAt(0)=='a'){
       \\do something
    }else{
    if(Word.charAt(0)=='''){
       \\do something else
    }

     
    Now, Word.charAt(0)==''' isnt allowed. In fact netbeans wont even let me type it. How do I overcome this?

    Thanks in advance
     
  2. jcsd
  3. Oct 12, 2011 #2

    Borek

    User Avatar

    Staff: Mentor

    I would try '\''.

    But I can be wrong.
     
  4. Oct 12, 2011 #3

    K29

    User Avatar

    That worked. Thank you.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Java-what if char is: '
  1. Java prob. (Replies: 1)

  2. HeapSort Java (Replies: 3)

Loading...