Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Java
»
Beginning Java
How to read characters from a string ?
Rohit Prakash Khare
,
Greenhorn
Jun 10, 2002 11:26:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
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.
arun mahajan
,
Ranch Hand
Jun 10, 2002 11:51:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
To find the length of string use length() method AND THAN RUN IT IN A for loop fo charter finding perhaps folowin code willhelp:
String x = "This is my test"; char[] xh = new char[x.length()]; for(int i=0;x.length();i+) { ch[i]=x.charAt(i); }
hope it may help...
Arun
Rohit Prakash Khare
,
Greenhorn
Jun 10, 2002 11:57:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Thanks Arun, I will sure try.
John Loney
,
Greenhorn
Jun 10, 2002 18:51:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Another approach similar to the $mid is
substr(int begpos,int endpos) in a for loop
Post by:
autobot
A magnificient life is loaded with tough challenges. En garde tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
This thread has been viewed 23375 times.
Similar Threads
Calling correct methods
how to read character from command line and store it string
identify and replace special character
what is the limitation of getString(column name)?
Magnetic Card Swipe Reader input to Console
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:21:05
.