简体   繁体   中英

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".

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;
   }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM