Question:
Java - Strange Compilation Error?
Nick
2012-07-31 09:17:53 UTC
I am getting a strange compilation error when I attempt to compile this code:

public class Reel2{
public static final int NUMBER_OF_SYMBOLS = 5;
private int currentIndex;
private int direction;
private Symbol[] symbols = new Symbol[NUMBER_OF_SYMBOLS]; // I have a created Symbol object class in the same directory.

}

The error I get is:

.\Symbol.java:9: illegal start of type
*//
.\Symbol.java:9: ';' expected
*//^

What does this even mean, and where are those characters coming from?

This only occurs when I try to create the Symbol array, it compiles fine without it.
Three answers:
2012-07-31 09:46:24 UTC
The error is in your Symbol object class code, not Reel2 code.
broom
2017-02-22 18:35:21 UTC
situation a million: Your different procedures are interior of considerable. situation 2: Your inner maximum variables should not be in the scope of considerable, yet with the class's scope. place them once you declare the class. Doing so will enable this technique to assemble suited. public classification Calculation { inner maximum double AnnualSalary; inner maximum double AnnualSales; inner maximum double value; inner maximum double acceleration; public static void considerable( String[] args ) { } public Calculation() { AnnualSalary = 0; AnnualSales = 0; value = 0; acceleration = 0; } public Calculation( double aSalary, double aSales, double acommission, double aAcceleration ) { AnnualSalary = aSalary; AnnualSales = aSales; value = acommission; acceleration = aAcceleration; } public void setAnnualSalary(double aSalary) { AnnualSalary = aSalary; } public void setAnnualSales( double aSales ) { AnnualSales = aSales; } public void setcommission( double acommission ) { value = acommission; } public void setacceleration( double aAcceleration ) { acceleration = aAcceleration; } public double getAnnualSales() { return AnnualSales; } public double calculateCalculation() { if ( AnnualSales < 64000 ) { return AnnualSalary; } else if ( AnnualSales >= 64000 && AnnualSales < 80000) { return AnnualSalary + ( AnnualSales * value ); } else { return AnnualSalary + ( AnnualSales * ( value * acceleration )); } } } What i observed above i fixed in this. in case you create a driving force classification, and attempt to create gadgets from this classification, it incredibly is going to artwork out completely fantastic. stable success, ~Barolb
Laurence I
2012-07-31 09:26:46 UTC
the brace







whenever you start learning a new language its always a good idea to hook

up your learning to some college or university that provides helpful stuff.

have a snoop around .edu sites and find one you like.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...