Computer Science, asked by gs160160, 6 months ago

Write a program in Java to input 10 words in an array. Extract the word at index 5 and delete it. Print the resultant array. Now check whether that deleted word still exists in array. Print appropriate messages.

Answers

Answered by lalitnit
1

Answer:

import java.util.*;

class JavaExample{

public static void main(String args[]){

ArrayList<String> alist=new ArrayList<String>();

alist.add("Steve");

alist.add("Tim");

alist.add("Lucy");

alist.add("Pat");

alist.add("Angela");

alist.add("Tom");

//displaying elements

System.out.println(alist);

//Adding "Steve" at the fourth position

alist.add(3, "Steve");

//displaying elements

System.out.println(alist);

}

}

Output:

[Steve, Tim, Lucy, Pat, Angela, Tom]

[Steve, Tim, Lucy, Steve, Pat, Angela, Tom]

Similar questions