Forums Register Login

Cannot find symbol error

+Pie Number of slices to send: Send
Most times when i try to compile this is what i do get,i am a complete newbie and i will like to know what i am doing that is wrong.Most of the tie the errors are always cannot find symbol.Below is an example:

C:\Documents and Settings\User\My Documents\Bicycle.java:19: cannot find symbol
symbol : method printIn(java.lang.String)
location: class java.io.PrintStream
System.out.printIn("cadence:"+cadence+"speed:"+speed+"gear:"+gear);
^
1 error

Tool completed with exit code 1

This is the program i tried to run

import java.lang.*;
class Bicycle{
int cadence=0;
int speed=0;
int gear=1;
void changeCadence(int newValue) {
cadence=newValue;
}
void changeGear(int newValue) {
gear=newValue;
}
void speedUp(int increment) {
speed=speed+increment;
}
void applyBrakes(int decrement) {
speed=speed-decrement;
}
void printStates() {
System.out.printIn("cadence:"+cadence+"speed:"+speed+"gear:"+gear);
}
}
+Pie Number of slices to send: Send
The method:

println();

is misspelled. It is short for "print-line" -- not for "print-In".

Kaydell
+Pie Number of slices to send: Send
It should be println (all lowercase, where the second to the last character is a lowercase 'L' -- not an uppercase 'I').
+Pie Number of slices to send: Send
"Abbey,"

Welcome to JavaRanch!

Please revise your display name to meet the JavaRanch Naming Policy. To maintain the friendly atmosphere here at the ranch, we like folks to use real (or at least real-looking) names, with a first and a last name.

You can edit your display name here. Thank you for your prompt attention!

-Marc
+Pie Number of slices to send: Send
Thanks so much for the advice it really works but when i try to run it is giving me
"exception in thread "main" java.lang.NoSuchMethodError: main"
+Pie Number of slices to send: Send
Please don't ignore the request to change your display name. Accounts get deleted.

Dave
+Pie Number of slices to send: Send
 

This is the program i tried to run

import java.lang.*;
class Bicycle{
int cadence=0;
int speed=0;
int gear=1;
void changeCadence(int newValue) {
cadence=newValue;
}
void changeGear(int newValue) {
gear=newValue;
}
void speedUp(int increment) {
speed=speed+increment;
}
void applyBrakes(int decrement) {
speed=speed-decrement;
}
void printStates() {
System.out.printIn("cadence:"+cadence+"speed:"+speed+"gear:"+gear);
}
}



First of all look at the java ranch naming policy and change your name. If the above program is your complete program then it wont run because execution starts from main() method you need to write a main() method. Signature of main() method public static void main(String[] args).



Regards
NIK
SCJP 1.5
+Pie Number of slices to send: Send
 

Originally posted by Abbey:
Thanks so much for the advice it really works but when i try to run it is giving me
"exception in thread "main" java.lang.NoSuchMethodError: main"



That is because your program doesn't have a main method. You need a method with the following signature:

public static void main(String[] args)

See The Java Tutorial for more info.
Please do not shoot the fish in this barrel. But you can shoot at this 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 906 times.
Similar Threads
Initializing Instance Members
7 errors for beersong source code in HFJ
It compiled but couldn't run,help me make it run
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:42:29.