This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes String Manipulation...cont! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "String Manipulation...cont!" Watch "String Manipulation...cont!" New topic
Author

String Manipulation...cont!

Jim Hooper
Greenhorn

Joined: Dec 13, 2004
Posts: 13
Mmmm...think I'm missing something here...my 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 -
Java_4a.java:29: 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
Greenhorn

Joined: Dec 13, 2004
Posts: 13
Thankyou again Steven! )
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: String Manipulation...cont!
 
Similar Threads
Integer.parseInt
need help
String Manipulation
String = char -- didnolikethis!
Recursion Functions: The proper condition to stop it