Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to replace an element in array in java

class array{
  public static void main(String[] args){
    int arr[] = {1,2,3,4};
    System.out.println("Before update" + arr[2]);
    arr[2] = 9;//updating the value
    System.out.println("After update" + arr[2]);
  }
}

/*output:-
Before update3
After update9*/
 
PREVIOUS NEXT
Tagged: #replace #element #array #java
ADD COMMENT
Topic
Name
8+7 =