Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes working with Strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "working with Strings" Watch "working with Strings" New topic
Author

working with Strings

gayathriy Nandakumar
Greenhorn

Joined: Jul 11, 2006
Posts: 15
Hi ..i am working with Strings and i have a requirement where i have to create a unique number for each string entered without the help of built-in functions and i have one more question...how do i get the ascii number for each character in a string??
thanks
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
use charAt() to access each char, which is an integral value.


"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Java doesn't use ASCII, it uses Unicode; but for your purposes, Unicode is a superset of ASCII.

In Java, as in C and many other similar language, a character is an integral type; it is it's own "ASCII code". You can just cast a char to an int, although even that isn't needed most of the time:

int asciiCode = (int) myChar;


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: working with Strings
 
Similar Threads
Array of Strings
How many objects can you create in JVM with very large RAM.
swing actionListeners
Naming Arrays
Quickie question about DataInput and Output Streams