Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Learn the STATIC keyword in 8 minutes! 🤝
Play lesson

Java tutorial for beginners ☕ - Learn the STATIC keyword in 8 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) { // static = Modifies a variable or method belong to the class, // rather than to any specific object. // Commonly used for utility methods or shared resources. Friend friend1 = new Friend("Spongebob"); Friend friend2 = new Friend("Patrick"); Friend friend3 = new Friend("Squidward"); Friend friend4 = new Friend("Sandy"); Friend.showFriends(); } } public class Friend { static int numOfFriends; String name; Friend(String name){ this.name = name; numOfFriends++; } static void showFriends(){ System.out.println("You have " + numOfFriends + " total friends"); } }

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