Phương thức nào sau đây cho phép chèn thêm một phần tử vào một vị trí của ArrayList? void add(int index, Object elem) Object remove(int index) boolean remove(Object) boolean add(Object)
Question
Phương thức nào sau đây cho phép chèn thêm một phần tử vào một vị trí của ArrayList? void add(int index, Object elem) Object remove(int index) boolean remove(Object) boolean add(Object)
Solution
Phương thức cho phép chèn thêm một phần tử vào một vị trí của ArrayList là void add(int index, Object elem). Phương thức này cho phép bạn chèn một đối tượng vào vị trí cụ thể trong ArrayList. index là vị trí bạn muốn chèn và elem là đối tượng bạn muốn chèn vào.
Similar Questions
Sau khi thực hiện đoạn mã sau thì ArrayList chứa những phần tử nào? int x = 1; Integer y = 3; ArrayList a = new ArrayList(); a.add(3); a.add(9); a.add(5); a.remove(x); a.remove(y);
Phương thức nào sau đây cho phép xoay vòng các phần tử trong ArrayList? void rotate (List list, int distance) void reverse (List list) void swap(List list, int i, int j) void sort (List list)
Đâu là phát biểu đúng nhất về ArrayList không định kiểu? Khi truy xuất các phần tử, cần ép về kiểu gốc của phần tử để xử lý Tất cả các đáp án trên điều đúng ArrayList không định có thể chứa các phần tử bất kể loại dữ liệu gì. Các phần tử trong ArrayList được đối xử như một tập các đối tượng (kiểu Object)
关于数组或ArrayList的长度,以下哪个陈述是不正确的?对于ArrayList,可以通过一个ArrayList方法的返回值来获得对于Java数组,可以通过一个Java数组方法的返回值来获得对于Java数组和ArrayList,数组的最高索引等于数组中的元素数量减去1ArrayList的长度在声明后可以被更改Java数组的长度在声明后无法更改如果您认为上述所有陈述都是正确的,请选择此选项。
What is the output of the following program:import java.util.ArrayList;class Main { public static void main(String[] args){ ArrayList<String> animals = new ArrayList<>(); animals.add("Dog"); animals.add("Cat"); animals.add("Horse"); animals.remove(2); System.out.println("ArrayList: " + animals); }}Select one:a.ArrayList: [Dog, Cat]b.ArrayList: [Horse]c.ArrayList: [Dog, Cat, Horse]d.ArrayList: [Dog]
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.