Java error cannot find symbol?

by 4 replies
6
/**
* Print to the screen.
*
* @author Beginner.
*/
public class Mag {


public static void main(String[] args) {

double circumference = 2 * Math.PI * radius;

System.out.println ("slant height (s): " + circumference);


}
}


I get:
Beginner.java:13: error: cannot find symbol
double circumference = 2 * Math.PI * radius;
......................................... ^

symbol: variable radius
location: class Beginner


Please help!
Thanks
#programming #error #find #java #symbol
  • The radius variable is not declared. Use this code,

    Code:
    /**
    * Print to the screen.
    *
    * @author Beginner.
    */
    public class Mag {
    
    public static void main(String[] args) {
    
    int radius = 10;
    
    double circumference = 2 * Math.PI * radius;
    
    System.out.println ("slant height (s): " + circumference);
    
    
    }
    }
  • My guess is that you have a problem with your classpath or you path settings.
  • Its not the classpath
    Just as handyman suggested, the radius variable is not declared.
    • [1] reply

Next Topics on Trending Feed