Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

non access modifiers in java

class StaticExample {
    public static int staticInt = 0;
    public int normalInt = 0;
    
    // We'll use this example to show how we can keep track of how many objects
    // of our class were created, by changing the shared staticInt variable
    public StaticExample() {
        staticInt++;
        normalInt++;
    }
}
Source by stackabuse.com #
 
PREVIOUS NEXT
Tagged: #access #modifiers #java
ADD COMMENT
Topic
Name
5+9 =