Results 1 to 5 of 5
  1. #1
    Valkyrie is offline Member
    Join Date
    Oct 2009
    Posts
    15
    Rep Power
    0

    Default Convert integers into ACSII characters.

    Does Java have a variant of the fromCharCode() method that is found in JavaScript?

    This is the what I want to accomplish in Java:

    Java Code:
    <script type="text/javascript">
    
    document.write(String.fromCharCode(72, 69, 76, 76, 79));
    
    </script>
    This JavaScript changes each digit to a ASCII character according to the number. So, does Java have a similar method to convert digits into ASCII characters?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    try
    Java Code:
        byte[] asciiBytes = {72, 69, 76, 76, 79};
        System.out.println(new String(asciiBytes));

  3. #3
    Valkyrie is offline Member
    Join Date
    Oct 2009
    Posts
    15
    Rep Power
    0

    Default

    Ok, thank you Fubarable for your help. One more question, how do add a variable in using byte[]?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Valkyrie View Post
    Ok, thank you Fubarable for your help. One more question, how do add a variable in using byte[]?
    What do you mean?

  5. #5
    Valkyrie is offline Member
    Join Date
    Oct 2009
    Posts
    15
    Rep Power
    0

    Default

    Like having variable var in byte[] = {var}, assuming that var is a number.

Similar Threads

  1. Sorting 3 Integers Using If Else
    By MSteinman in forum New To Java
    Replies: 12
    Last Post: 02-19-2010, 01:52 PM
  2. Replies: 4
    Last Post: 09-07-2008, 04:58 PM
  3. Random Integers
    By www.kwalski.com in forum Java Applets
    Replies: 8
    Last Post: 12-09-2007, 06:49 PM
  4. Replies: 1
    Last Post: 08-07-2007, 06:32 AM
  5. Convert roman numerals to integers
    By Felissa in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 12:27 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
  •