Hello I am new to Java and had a quick question about looking for the name of a String in an ArrayList. Here is the code I wrote:
import java.util.*;
public class Rubix{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
String input;
String FRS="U (R U' R')";
String RBS="y' U' (R' U R)";
String FLD="y' (R' U' R)";
ArrayList RA = new ArrayList();
RA.add(FRS);
RA.add(RBS);
RA.add(FLD);
System.out.println("Name the situation.");
input=sc.nextLine();
for(int i=0; i<RA.size(); i+=1){
if (input==RA.get(i)){
System.out.println(RA.get(i));
}
}
}
}
What I am asking for help with is writing the if statement. I want to test to see if that name for the String is within the ArrayList. I know what I have currently is wrong so please help.
if (RA.contains(input)), also,=is assignment, not comparison