0

I have seen this work in C# and wanted to ask if there is a way of doing this in Java as well? if lets say we have a class student:

public class Student {

private long id;
private String fName;
private String mName;
private String lName;

public Student();

}

In c# if we wanted to instantiate that class you would be able to do the following:

Student student = new Student(){ 
id = 1,
fName = "Alex", 
lName = "Joe" };

and an instance of a student would be created with only id fName and lName filled out and mName would be null. Is there any such option in Java that would work accordingly?

0 Answers0