0
import java.util.*;

enum CITY{ROME,BUDAPEST,PARIS,GREECE,TALIN,AMSTREDAM,VIENNA;}

class Flight{
    private String flightName = "AirBus";
    private int ticketPrice = 50;
    private CITY Destination = CITY.ROME;
    private int numberOfTravellers = 83;
    private int flightDuration = 2;
    Calendar flightTime = Calendar.getInstance();
    Calendar flightDate = Calendar.getInstance();
    flightDate.set(Calendar.YEAR, 2002);
    flightDate.set(Calendar.MONTH, 2);
    flightDate.set(Calendar.DAY, 20);
    flightTime.set(Calendar.HOUR,10);
    flightTime.set(Calendar.MINUTE, 0);
    flightTime.set(Calendar.SECOND, 0);

    private static int goalTicketPrice = 35;
}

I am tring to set the Date and time of the flight. but getting these types of 18 errors.

It gives this error ....

<identifier> expected
    flightDate.set(Calendar.YEAR, 2002);
 
Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
  • 1
    You should not use the `Calendar` class. It is cumbersome to work with and long outdated. I think you want `ZonedDateTime flightDateTime = ZonedDateTime.of(2002, 3, 20, 22, 0, 0, 0, ZoneId.systemDefault());`. The `ZonedDateTime` class is part of [java.time, the modern Java date and time API](https://docs.oracle.com/javase/tutorial/datetime/index.html). – Ole V.V. Dec 07 '22 at 15:29
  • 1
    Completely aside: The capital of Estonia is spelled *Tallinn* with double l and double n. Greece is not a city, you may have thought `ATHENS`? – Ole V.V. Dec 07 '22 at 15:34

0 Answers0