xxxxxxxxxx
class array{
public static void main(String[] args){
int arr[] = {1,2,3,8};
System.out.println("Before update" + arr[2]);
arr[2] = 9;//updating the value
System.out.println("After update" + arr[2]);
}
}
xxxxxxxxxx
list.set(1,"new value");
//example ..
List<String> list = new ArrayList<>();
list.add("one");
list.add("two");
list.add("three");
System.out.println(list); // [one,two,three]
list.set(1,"new");
System.out.println(list); //[one,new,three]
xxxxxxxxxx
import java.util.ArrayList;
class Main {
public static void main(String[] args) {
ArrayList<String> languages = new ArrayList<>();
// add elements in the array list
languages.add("Java");
languages.add("Kotlin");
languages.add("C++");
System.out.println("ArrayList: " + languages);
// change the element of the array list
languages.set(2, "JavaScript");
System.out.println("Modified ArrayList: " + languages);
}
}
xxxxxxxxxx
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]);
}
}
xxxxxxxxxx
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]);
}
}
xxxxxxxxxx
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]);
}
}
xxxxxxxxxx
class array{
public static void main(String[] args){
int arr[] = {1,2,3,8};
System.out.println("Before update" + arr[2]);
arr[2] = 9;//updating the value
System.out.println("After update" + arr[2]);
}
}