“Java Arraylist hapus” Kode Jawaban

Java Arraylist hapus

//create ArrayList
ArrayList<String> arrayList = new ArrayList<String>();
//add item to ArrayList
arrayList.add("item");
//check if ArrayList contains item (returns boolean)
System.out.println(arrayList.contains("item"));
//remove item from ArrayList
arrayList.remove("item");
Change The Mentality

Java menghapus elemen arraylist

import java.util.ArrayList;

class Main {
  public static void main(String[] args) {
    ArrayList<String> animals = new ArrayList<>();

    // add elements in the array list
    animals.add("Dog");
    animals.add("Cat");
    animals.add("Horse");
    System.out.println("ArrayList: " + animals);

    // remove element from index 2
    String str = animals.remove(2);
    System.out.println("Updated ArrayList: " + animals);
    System.out.println("Removed Element: " + str);
  }
}
SAMER SAEID

Hapus Elemen ArrayList Menggunakan Fungsi Lepaskan ()

import java.util.ArrayList;

class Main {
  public static void main(String[] args) {
    ArrayList<String> animals = new ArrayList<>();

    // add elements in the arraylist
    animals.add("Peacock");
    animals.add("Markhor");
    animals.add("Cow");
    System.out.println("ArrayList: " + animals +"\n");

    // remove element from index 2
    String str = animals.remove(2);
    System.out.println("Updated ArrayList: " + animals);
    System.out.println("Removed Element: " + str);
  }
}
Outrageous Ostrich

Jawaban yang mirip dengan “Java Arraylist hapus”

Pertanyaan yang mirip dengan “Java Arraylist hapus”

Lebih banyak jawaban terkait untuk “Java Arraylist hapus” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya