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.
A friendly place for programming greenhorns!
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
Author
String Manipulation...cont!
Jim Hooper
Greenhorn
Joined: Dec 13, 2004
Posts: 13
posted
Jan 05, 2005 11:48:00
0
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
posted
Jan 05, 2005 12:01:00
0
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
posted
Jan 05, 2005 12:21:00
0
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
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter