Answers for "how to change array of arrays java"

3

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*/
Posted by: Guest on August-11-2020
3

java how to change the length of an array

The size of an array cannot be changed after instantiation
If you need to change the size, create a new array and copy the contents
or use an ArrayList which does require a set size
Posted by: Guest on May-17-2020

Code answers related to "how to change array of arrays java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language