
If anyone could help me with this I would be really thankful!
Write a program that stores the names of these artists in a String array. The program should prompt the user to enter the name of an artist and output that artist's position in the charts or a message saying that they are not present.
You should choose the most appropriate search method introduced in the lecture and modify it so that it handles strings, rather than integers.

import java.util.*;
class SearchingAndSorting
{
public static void main(String[] args)
{
String names[]={"AAAA","DDDD","FFFF","ZZZZ","KKKKK","PPPP"};
ArrayList<String> list=new ArrayList<String>();
for(int i=0;i<names.length;i++){
list.add(names[i]);
}
Scanner input=new Scanner(System.in);
System.out.print("Enter Name: ");
String name=input.nextLine();
int index;
if(list.contains(name)){
index=list.indexOf(name);
System.out.println("Position: "+(index+1));
}
else{
System.out.println("Artist is not present");
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.