I assume you would like to swap temp1 and temp2. So if you define a variable in Java, the type (in this case String) is placed at the beginning of the line, followed by the variable name (in this case temp1 & temp2)
So it should be
Also, you defined lastGroceryItem inside the condition, then attempted to retrieve the value outside of it. In case you are not familiar with the concept of scope, here’s a quick explain:
You define a scope with { }. The variable created in it is only accessable within the scope. Variables defined outside all existing scope are called Global Variables.
So define lastGroceryItem outside the condition, then change its value when groceryList.length > 1.