Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot find symbol error  RSS feed

 
Abbey Samuel
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
}
}
 
Kaydell Leavitt
Ranch Hand
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method:

println();

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

Kaydell
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be println (all lowercase, where the second to the last character is a lowercase 'L' -- not an uppercase 'I').
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Abbey Samuel
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't ignore the request to change your display name. Accounts get deleted.

Dave
 
Nik Arora
Ranch Hand
Posts: 652
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!