user10610048
user10610048

Reputation: 127

Why can't I use GregorianCalendar as an object type as a constructor parameter?

Why can't I use GregorianCalendar as an object type as a constructor parameter?

public class P(GregorianCalendar date){

Why can't I do this?

The error it give me is "syntax error on token "class", char expected".

Upvotes: 1

Views: 98

Answers (1)

k5_
k5_

Reputation: 5568

As Jon Skeet mentioned in the comments. Here is how you create a class with construtor that has one parameter

import java.time.LocalDate;

public class P {
   private LocalDate date;
   public P(LocalDate date){
      this.date = date;
   }
}

Upvotes: 2

Related Questions