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); } }
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!
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).
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: