Two Laptop Bag*
The moose likes Beginning Java and the fly likes How to read characters from a string ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to read characters from a string ?" Watch "How to read characters from a string ?" New topic
Author

How to read characters from a string ?

Rohit Prakash Khare
Greenhorn

Joined: Jun 09, 2002
Posts: 6
Hi,
In my java program I accepted string from the user and now I want to calculate the length of the string, and then read characters one by one to encrypt it.
How to read the characters one by one ? Like Mid$ function in VB.


"As long as there are tests, there will be prayer in public <br />schools."
arun mahajan
Ranch Hand

Joined: Dec 07, 2001
Posts: 305
To find the length of string use length() method AND THAN RUN IT IN A for loop fo charter finding perhaps folowin code willhelp:

hope it may help...
Arun
Rohit Prakash Khare
Greenhorn

Joined: Jun 09, 2002
Posts: 6
Thanks Arun, I will sure try.
John Loney
Greenhorn

Joined: Jun 03, 2002
Posts: 4
Another approach similar to the $mid is
substr(int begpos,int endpos) in a for loop
 
Consider Paul's rocket mass heater.
 
subject: How to read characters from a string ?