chima
asked on
Java ArrayList and if statement
Hello,
On the first if statement below, I'm trying to branch on a String comparison. When I print these elements they look the same to my eyes, but the compiler does not agree. So what am I doing wrong.
On the first if statement below, I'm trying to branch on a String comparison. When I print these elements they look the same to my eyes, but the compiler does not agree. So what am I doing wrong.
while(inCount <= 12){ // 12 is the variable that controls the growth of the Arraylist
listArrays.add(Arrays.asList(inCount + 0.1));
System.out.println("Current element in list Arrays: " + inCount +" "+ listArrays.get(inCount) + "\n");
//int count=listArrays.size();
boolean found = false;
String comString = listArrays.get(inCount).toString();
comString = comString.substring(1, comString.length() - 1);
System.out.print("This is the comString: " + comString.toString() + "\n");
if(comString.toString() == "7.1"){found = true;
if(found){
System.out.println("Bingo! You found it); " + listArrays.get(inCount) + "\n");
continue;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'll have other questions, and I do appreciate your help. I'm working on HashMap now so please stay tuned.