Also das ist nur ein Teil meines Codes, und das gesamte Programm kompiliert und funktioniert, aber ich bekomme immer "lokale Variable verbirgt ein Feld" neben Zeilen drei aufeinander folgenden Zeilen beginnend mit "GameBoard myBoard = this.getGameBoard();". ich bin nur neugierig, was das eigentlich bedeutet, und wenn es etwas zu meinem Programm auf lange Sicht tutWas bedeutet lokale Variable verbirgt ein Feld?
public void initialze(){
myBoard = getGameBoard();
obstacleLocations = myBoard.getObstaclePositions();
pastureLocations = myBoard.getPasturePositions();
GameBoard myBoard = this.getGameBoard();
ArrayList<GameLocation> obstacleLocations = myBoard.getObstaclePositions();
ArrayList<GameLocation> pastureLocations = myBoard.getPasturePositions();
GameLocation closestPasture = pastureLocations.get(0);
GameLocation closestObstacle = obstacleLocations.get(0);
Es ist weil Sie Variablennamen wiederverwenden. Achten Sie auf Ihre Benennung und verhindern Sie Dubletten. – CubeJockey