How to Overwrite an Existing Variable Value in Java


In this example, we will learn the method to overwrite an existing variable value in Java.

Source Code

package com.beginner.examples;

public class OverwriteVariable {
  public static void main(String[] args) {
    int i = 1;
    i = 12;  // overwrite an existing variable value
    System.out.println(i);
  }
}

Output:

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