How to Modify Class Attributes in Java


In this example, we will learn the method to modify class attributes in Java.

Source Code

package com.beginner.examples;

public class ModifyClassAttribute {
  int a;

  public static void main(String[] args) {
    ModifyClassAttribute c = new ModifyClassAttribute();
    c.a = 7; // modify attributes
    System.out.println(c.a);
  }
}

Output:

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