• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cannot find symbol error

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
}
}
 
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The method:

println();

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

Kaydell
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please don't ignore the request to change your display name. Accounts get deleted.

Dave
 
Ranch Hand
Posts: 652
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic