aspose file tools*
The moose likes Beginning Java and the fly likes Ascii letters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Ascii letters" Watch "Ascii letters" New topic
Author

Ascii letters

Paolo Dina
Ranch Hand

Joined: Aug 15, 2008
Posts: 63


I'm sure something like this (or similar) is defined somewhere. Where? I looked at Character's fields but I found nothing. Any idea?

Thanks


SCJP 5
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Do you know about Unicodes??


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

No, there aren't any arrays of lower case letters defined in the API. What there is, is a lot of methods in the java.lang.Character class which you can use to ask whether a character is a letter, number, lowercase, uppercase, etc. As Ankit points out, Java uses Unicode, not ASCII, so some of these questions are a little bit tricky.


[Jess in Action][AskingGoodQuestions]
Paolo Dina
Ranch Hand

Joined: Aug 15, 2008
Posts: 63


If I want to print characters from a to z, shoud I define my constant (as in the example) or I can find one already defined? Hope my question makes sense.

Thanks

P.S.
Thanks Ernest, that was the answer I was looking for.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Well I can provide a complete code but I think it would be fun if you experiment with it yourself. I would just give you some hints. create a character variable with the value 'a'. Then use the Character.numericValue method along with the ability to assign an int value into a char variable to attain what you want. I hope you would have fun experimenting with the stuff ...
Paolo Dina
Ranch Hand

Joined: Aug 15, 2008
Posts: 63


Much better if there was a static field to be used out of the box ;-)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38340
    
  23
Character#numericValue doesn't do what you think it does. But it is still worthwhile going through the Character class, because it has all sorts of useful isSomething methods.
Don't use 97; you are a computer scientist now. Use 0x61. You can find the ASCII values from Unicode because this PDF is identical to ASCII. Note the values are in hexadecimal.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

And have a look at the Character.UnicodeBlock class -- that might relate to your question. There's a lot in Unicode besides ASCII.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Paolo Dina wrote:
Much better if there was a static field to be used out of the box ;-)


Even given that this is what you actually want, you could replace that magic 97 with 'a'. Or replace the whole routine with

"abcdefghijklmnopqrstuvwxyz".toCharArray();

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ascii letters