File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "working with Strings" Watch "working with Strings" New topic

working with Strings

gayathriy Nandakumar

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 do i get the ascii number for each character in a string??
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

Joined: Jul 08, 2003
Posts: 24199

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:
subject: working with Strings
It's not a secret anymore!