Results 1 to 6 of 6

Thread: [Resolved] chr() in Java?

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Resolved [Resolved] chr() in Java?

    Is there a such thing in Java as chr()? such as chr(65) = 'A'?
    Last edited by The Hobo; Oct 10th, 2004 at 11:48 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    char a = (char)65;
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Thanks, CB. I couldn't figure out how to search for this one.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Since the assignment results in an implicit narrowing primative conversion no cast is needed. If the source is an int constant whos value can be determined to be in the range of the destination type byte short or char then you can omit the type cast.

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Yes, but not if he casts from an int variable, which is what he'll do most of the time, so showing the cast makes sense.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Code:
    Posted by CornedBee
    
    Yes, but not if he casts from an int variable.
    Yes of course.
    Code:
     int i = 65; 
     char c = (char)i;
    Just wanted to point out that the cast was not needed with the expression you posted. You never know he might want to take the SCPJ2 exam. Sun sure does get dam pickey.

Posting Permissions

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



Click Here to Expand Forum to Full Width