Static and Non-Static

java dev.to

1. What is Static in Java? - A static variable or method belongs to the class, not to objects. This means only one copy exists and all objects share it. To call a static method, it is not necessary to create an object. Example: class Student { static String college = "ABC College"; String name; } public class Main { public static void main(String[] args) { Student s1 = new Student(); Student s2 = new Student(); System.out.println(Student.college)

Read Full Tutorial open_in_new
arrow_back Back to Tutorials