Constructor not a statement
When I try to compile normally, I get an unchecked/unsafe error, and when I ignore it I get an error for each insance where I try to use my Car constructor. The error is Car.java:35: not a statement, with the little arrow pointed at the 'c' in car1, car2, and car3. My code is:
Code:
class Car
{
String plateNumber;
boolean permit;
int Time;
List plateList = Arrays.asList( new String[] {} );
Car( String plate )
{
this.plateNumber = plate;
if ( plateList.contains( plate ))
{
boolean permit = true;
System.out.println( "Car " + plate + " has a permit" );
}
else
{
plateList.add( plate );
boolean permit = false;
System.out.println( "Car " + plate );
}
}
public static void main(String[] args)
{
Car car1, car2, car3;
car1 = new Car( "123 ABC" );
car2 = new Car( "123 abc" );
car3 = new Car( "123ABC" );
}
}
I would appreciate any help. Also, is there a way to keep my code format when I post? It would make it easier to read.