tubeshowcase●1,661,801 videos♡ My collection 0
← Learn to Code

Learn to Code08:01

Learn the STATIC keyword in 8 minutes! 🤝

Bro Code ↗

From the creator

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

Published 2024-12-05 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.

Keep exploring Learn to Code