Calling an object while creating another object

6

I have a Person class and a Date class, the Person class creates a person the date class creates a date to use as the date of birth in the Person class, how is it that when creating a Person I create a date without having to use the code complete in the middle of the person object, the code created so far is this:

public static void main(String[] args) {
        Data d = new Data(0, 0, 0);
        Pessoa p = new Pessoa("Miguel", "Rua D. Maria", "7400604", objeto_data, "Solteiro");

    }
    
asked by anonymous 26.07.2016 / 23:43

1 answer

6

It is possible to create the direct date in the command, according to the code below:

Pessoa p = new Pessoa("Miguel", "Rua D. Maria", "7400604", new Data(0, 0, 0), "Solteiro");

Or create this date in the constructor of the Person class.

    
27.07.2016 / 00:03