ItsJustme ItsJustme - 3 months ago 33
Android Question

If, else if statement not working in Android studio

maybe it is something very small that I am missing but somehow my if statement doesn't work. I want to check if the x of the position of a picture if greater than the screen width but somehow i get the errors:


"else without if" and ")" or "; expected"


Here is my code:

if (image.getX() => screenWidth){
image.animate().xBy(- (screenWidth + 120));
} else if (image.getX() <= -120){
image.animate().xBy(screenWidth+120).setDuration(5000).start();
}

Answer

=> is not a valid oeprator in Java, you re looking for >= (greater than or equal to)

Comments