Results 1 to 3 of 3
  1. #1
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default How to print the integer value of char : '

    Java Code:
    System.out.println((int) ' " ');
    System.out.println((int) ' ' ');
    The first line complies and runs, but the second one does not.

    Any help ?

    Eclipse says: Invalid character constant ?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,963
    Rep Power
    8

    Default Re: How to print the integer value of char : '

    Did you add those spaces for demonstration purposes?

    Try escaping the ' with a backslash. For example, to print out a " inside a String, you do this:

    Java Code:
    System.out.println("I contain \" quotation marks!");
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: How to print the integer value of char : '

    Yes for demonstration purposes.

    Thanks for the answer.

Similar Threads

  1. How to Print every tenth integer in my output
    By jim01 in forum New To Java
    Replies: 13
    Last Post: 04-16-2011, 03:00 AM
  2. check a string char by char
    By Sotsiak in forum New To Java
    Replies: 2
    Last Post: 10-23-2010, 09:24 PM
  3. replaceALL(char oldChar, char newChar) method
    By arson09 in forum New To Java
    Replies: 0
    Last Post: 04-28-2010, 05:48 AM
  4. drawing char by char with Graphics
    By diggitydoggz in forum New To Java
    Replies: 5
    Last Post: 12-27-2008, 12:49 PM
  5. need help print char and digital
    By lowpro in forum New To Java
    Replies: 4
    Last Post: 12-04-2007, 07:20 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
  •