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 String Manipulation...cont! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String Manipulation...cont!" Watch "String Manipulation...cont!" New topic

String Manipulation...cont!

Jim Hooper

Joined: Dec 13, 2004
Posts: 13
Mmmm...think I'm missing something code is as follows

public static void main(String[] args)
String numword = args[0];
String output;
int i;
int i1;
int i2;

if (numword.charAt(0) = "1")

but will not accept numword.charAt(0). Error - unexpected type
required: variable
found : value
if (numword.charAt(0) = "1")

Any help greatly appreciated!
Thanks again....
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
Originally posted by Jim Hooper:

if (numword.charAt(0) = "1")

should be

if (numword.charAt(0) == '1')

notice the double == and the single quotes.

Personally I would add some checks to ensure that there is a string passed in and that it has a lenght of at least 1. Just good a good habit to be in.
Jim Hooper

Joined: Dec 13, 2004
Posts: 13
Thankyou again Steven! )
I agree. Here's the link:
subject: String Manipulation...cont!
It's not a secret anymore!