Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass an empty array to the constructor in java?

This is the code:

// Default constructor
public Bestellung() {
    this(null, null, null);
}

// Initial constructor
public Bestellung(LocalDateTime zeitstempelBestellung, LocalDateTime zeitstempelAuslieferung,
        PizzaVO[] warenkorb, int index) {
    super(); 
    this.zeitstempelBestellung = zeitstempelBestellung;
    this.zeitstempelAuslieferung = zeitstempelAuslieferung;
    this.warenkorb = warenkorb;
    this.index = index;
}

I'd like to finish the default constructor. Therefore I have to pass two localDateTimes, one empty array and one int to the constructor. How do I pass the empty array?


1 Answers

How do I pass the empty array?

new PizzaVO[] { }

BTW, this is not a default constructor:

public Bestellung() {
    this(null, null, null);
}

it is a no-argument constructor.

like image 135
Adam Siemion Avatar answered Sep 23 '25 01:09

Adam Siemion