Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Learn CONSTRUCTORS in 10 minutes! 🔨
Play lesson

Java tutorial for beginners ☕ - Learn CONSTRUCTORS in 10 minutes! 🔨

5.0 (4)
40 learners

What you'll learn

This course includes

  • 12 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#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"); } }

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere