Hey guys! So I'm working on a program that accepts 7 user inputs then stores them in an ArrayList. Then it replaces elements that start with the letter "B" with an aterisk. I'm getting a IndexOutOfBoundsException. Here's the code I have: `
package arraylist1;
import java.util.*;
public class ArrayList1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<String> list = new ArrayList<String>();
String str = "";
for(int i=0;i<7;i++)
str = sc.next();
list.add(str);
for(int j=0; j<7;j++)
if(list.get(j).startsWith("B")==true)
list.set(j, " * ");
System.out.print(list);
}
}
`