Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

working with Strings

 
gayathriy Nandakumar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 490
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use charAt() to access each char, which is an integral value.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic