How to Override Existing Attribute Values in Java


In this example we will show the method to override existing attribute values in Java.

Source Code

package com.beginner.examples;

public class OverrideAttribute {
  int i = 25;

  public static void main(String[] args) {
    OverrideAttribute o = new OverrideAttribute();
    o.i = 17; // override existing attribute
    System.out.println(o.i);
  }
}

Output:

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