java - Why am I getting a "cannot find symbol" error when creating an object? -
when i'm trying create new object class defined, maintain getting "cannot find symbol" error, , there's arrow pointing towards "s" in first "snowfallreport" in constructor. i've had problem when trying create other objects in other programs , wanna throw laptop! sense it's simple solution, don't know is.
the code follows:
import java.util.random; public class snowfallreport { // random amount of snow private double snowamount; // default constructor creates random amount , assigns snowamount public void snowfallreport() { random snowfall = new random(); snowamount = (snowfall.nextdouble()) * 20; } public double getsnow() { homecoming snowamount; } public void getstars() { (int staramount = 0; staramount == snowamount; staramount++) { system.out.print("*"); } } public static void main(string[] args) { **snowfallreport day1 = new snowfallreport();** } }
java case sensitive language
snowfallreport != snowfallreport
your class name snowfallreport
create object like:
snowfallreport ref = new snowfallreport ();
also, constructor name should same class name , don't have homecoming type not void.
// default constructor creates random amount , assigns snowamount public void snowfallreport() {
should be
public snowfallreport() {
java
No comments:
Post a Comment