How to Access Class Attributes in Java


In this example we will show the method to access class attributes in Java.

Source Code

package com.beginner.examples;

public class ClassAttribute {
  int a = 70;

  public static void main(String[] args) {
    ClassAttribute c = new ClassAttribute();
    System.out.println(c.a);// access class attributes
  }
}

Output:

70
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments