missing return?

Sduni

Mitglied
Hi, ich habe folgendes Problem:

Warum gibt mir der compiler hier missing return statement aus?
Java:
public int getX ( int x, Direction direction )
    {
		switch(direction){
			case LEFT:
				if(existsYX(0,x,Direction.LEFT)) return x-1;
			case RIGHT:
				if(existsYX(0,x,Direction.RIGHT)) return x+1;
			case TOP:
				if(existsX(x)) return x;			
			case BOTTOM:
				if(existsX(x)) return x;
			case TOPLEFT:
				if(existsYX(0,x,Direction.LEFT)) return x-1;
			case BOTTOMLEFT:
				if(existsYX(0,x,Direction.LEFT)) return x-1;
			case TOPRIGHT:
				if(existsYX(0,x,Direction.RIGHT)) return x+1;
			case BOTTOMRIGHT:
				if(existsYX(0,x,Direction.RIGHT)) return x+1;
			case NONE:
				if(existsX(x)) return x;
			default:
				if(existsX(x)) return x;
		}
		
    }

Weil ein else fehlt?
 
Zuletzt bearbeitet:

ARadauer

Top Contributor
was passiert bei
default:
if(existsX(x)) return x;
wenn das existsX(x) false ist? dann gibtst du nichts zurück... sollst du aber...
 

Oben