Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
0
When you initialize an object, you can do so with values for the objects constructor if need be. For example: you create a class called Person. 2 variables String name, int age. You put these in the constructor. When you go to initialize the object in your main class, you'd initialize it like: Person person1 = new Person("Bill", 31); new object with the values given. Make another object, Person person2 = new Person("Larry", 8);. Your giving an object it's values for its existing variables
7th Jul 2016, 5:32 AM
James
James - avatar