Learn CONSTRUCTORS in 10 minutes! πŸ”¨ @BroCodez
Learn CONSTRUCTORS in 10 minutes! πŸ”¨  @BroCodez
Uploaded December 2024 | Updated September 2026, 1 week ago
#java #javatutorial #javacourse

public class Main {
public static void main(String[] args) {

// constructor = A special method to initialize objects
// You can pass arguments to a constructor
// and set up initial values

Student student1 = new Student("Spongebob", 30, 3.2);
Student student2 = new Student("Patrick", 34, 1.5);
Student student3 = new Student("Sandy", 27, 4.0);

System.out.println(student1.name);
System.out.println(student1.age);
System.out.println(student1.gpa);
System.out.println(student1.isEnrolled);

System.out.println(student2.name);
System.out.println(student2.age);
System.out.println(student2.gpa);
System.out.println(student2.isEnrolled);

System.out.println(student3.name);
System.out.println(student3.age);
System.out.println(student3.gpa);
System.out.println(student3.isEnrolled);

student1.study();
student2.study();
student3.study();
}
}
public class Student {

String name;
int age;
double gpa;
boolean isEnrolled;

Student(String name, int age, double gpa){
this.name = name;
this.age = age;
this.gpa = gpa;
this.isEnrolled = true;
}

void study(){
System.out.println(this.name + " is studying");
}
}
Learn CONSTRUCTORS in 10 minutes! πŸ”¨Learn Java while loops in 12 minutes! ♾️MongoDB indexes explainedArrays of structs are easy! πŸ—„οΈGenerate random numbers in C! 🎲Learn hexadecimal in 0x7A secondsLets code a HANGMAN GAME in Python! πŸ•ΊEnter USER INPUT into an ARRAY! ➑️Matplotlib grid lines in 2 minutes! 🌐Selection in Pandas is easy! 🎯Convert decimal to octal EASY!Learn INTERFACES in 6 minutes! πŸ“‹
Bro Code |

Learn CONSTRUCTORS in 10 minutes! πŸ”¨

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER