Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes Grabbing char from strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Grabbing char from strings" Watch "Grabbing char from strings" New topic

Grabbing char from strings

Tyler Jordan
Ranch Hand

Joined: Nov 17, 2003
Posts: 70
I have an array of strings that I need to query a specific char position of. Specifically, position 3 of an array of strings for a period. If the period shows up at a specific point in the string, its a type1 string and if the period is elsewhere its a type2 string. Is there anyway to grab the value of a specific char or int of a string? I'd rather not have to walk through all the characters of my array of strings when I can just request and test the value of one character. Here is the basic format I will be using.
eammon bannon
Ranch Hand

Joined: Mar 16, 2004
Posts: 140
Tyler Jordan
Ranch Hand

Joined: Nov 17, 2003
Posts: 70
Thanks for the reply.
At first I thought you misunderstood what I was asking for, but then I realized you were verifying the location differently than the way I was thinking. Your way is better. Thanks again.
Nick Way

Joined: Feb 06, 2004
Posts: 7
Or if you know where the period is supposed to be, you could use charAt(), e.g.
I agree. Here's the link:
subject: Grabbing char from strings
It's not a secret anymore!