public class Seat {
private int no;
private String class;
private boolean pos;
private boolean table;
private boolean dir;
private boolean access;
public Seat()
{
}
}
When I try to declare the String class I continue to get an error, I know it's probably something really simple.
You cannot use
class
as a variable name because it has a specific meaning in Java. Choose a different variable name for your string.You are using the reserved keyword
class
to name your variable, which won't compile.Use a non-reserved name for your
String
variable.See variable naming rules here, and reserved keywords here.
The
class
keyword is used to declare classes, such as in yourSeat
class declaration.The error is quite most detected in all the previous answers:
according to the Oracle web site:
abstract, continue, for, new, switch assert, default, goto, package, synchronized boolean, do, if, private, this break, double, implements, protected, throw byte, else, import, public, throws case, enum, instanceof, return, transient catch, extends, int, short, try char, final, interface, static, void class, finally, long, strictfp, volatile const, float, native, super, while
So, declaring a variable with any of those names will drive your compiler nuts, and it will complain about the syntax of the code.
class
is a reserved word of java try to rename with other name :