Complete the java code: import java.util.*; public class Solution { //driver function public static void main(String args[]) { //array of string String[] arr1={"10", "170", "5"}; //arraylist ArrayListlist //print if list is empty or not //add element in list list.add(2,"21"); list.add(2,"23"); //print list System.out.println("Out2: "+list); //remove and print element at index 1 in list //print list System.out.println("Out4: "+list); //print if list contains "010" or not //reverse list Collections.reverse(list); //print list }

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question

Complete the java code:

import java.util.*;

public class Solution {

//driver function

public static void main(String args[]) {

//array of string

String[] arr1={"10", "170", "5"};

//arraylist

ArrayList<String>list

//print if list is empty or not

//add element in list

list.add(2,"21");

list.add(2,"23");

//print list

System.out.println("Out2: "+list);

//remove and print element at index 1 in list

//print list

System.out.println("Out4: "+list);

//print if list contains "010" or not

//reverse list

Collections.reverse(list);

//print list

}

}

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Concept of memory addresses in pointers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT