Java: Wieso bekomme ich diesen Fehler ("ArrayIndexOutOfBoundsException: Index 9 out of bounds for length 9")?

Bei meinem Code kommt nach der Eingabe eines Wortes immer folgender Fehler.

Das ist alles von der Konsole:

Bitte geben Sie ein Wort für das B-Sprachen Spiel ein: Hallo
5
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 9 out of bounds for length 9
at B_SprachenSpiel/Lektion_7.B_SprachenSpiel.Spiel(B_SprachenSpiel.java:42)
at B_SprachenSpiel/Lektion_7.B_SprachenSpiel.main(B_SprachenSpiel.java:14)

Danach sollte eigentlich noch das Wort (in dem Fall Hallo) ausgegeben werden, nur dass es durch die Änderung dann Haballobo heißt. Das soll das Programm machen. Doch ich verstehe nicht, wieso immer wieder dieser Fehler kommt.

Folgendes ist mein kompletter Code von diesem Programm:

package Lektion_7;

import java.lang.reflect.Array;
import java.util.Scanner;

public class B_SprachenSpiel {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.print("Bitte geben Sie ein Wort für das B-Sprachen Spiel ein: ");
    String B = sc.nextLine();
    Spiel(B);

    // System.out.println("Das umgewandelte Wort lautet: " + Spiel(B));
  }

  public static void Spiel(String Wort) {
    char[] x = new char [100];
    x = Wort.toCharArray();
    System.out.println(x.length);
    int y = x.length;
    int lang = x.length;

    for (int i = 0; i < y; i++) {
      if (x[i] == 'a' || x[i] == 'e' || x[i] == 'i' || x[i] == 'o' || x[i] == 'u') {
        lang += 2;
      }
    }

    System.out.println(lang);
    char[] neu = new char[lang];

    for (int i = 0; i <= neu.length; i++) {
      if (neu[i] == 'a' || neu[i] == 'e' || neu[i] == 'i' || neu[i] == 'o' || neu[i] == 'u') {
        neu[i] = (char) (x[i] + 'b' + (char) x[i]);
      }
    }

    String z = x.toString();
    System.out.println("                         Das umgewandelte Wort lautet: " + String.valueOf(neu));
    // for (int i = 0; i <= x.length; i++)
    //		{
    //			System.out.print(x[i]);
    //		}
  }
}
Computer, programmieren, Java, Array, Informatik
Programm beenden in Java?

Biite so machen das es nach ner Zeit beendet (Zeit egal)

int numBalls = 5 + (int)(Math.random() * ((15 - 5) + 1));
float spring = 0.05;
float gravity = 0.03;
float friction = -0.9;
int score = 0;
int timer = 2;
int Java = 1;
Ball[] balls = new Ball[numBalls];




void setup() {
  size(1920, 920);
  for (int i = 0; i < numBalls; i++ ) {
    balls[i] = new Ball(random(width), random(height), random(30, 70), i, balls);
  }
  noStroke();
  fill(255, 204);
  //  circleColor = color(255);
}


void draw() {
  background(255, 255, 255);
  for (Ball ball : balls) {
    ball.collide();
    ball.move();
    ball.display();
  }
}


void mousePressed() {
  for (Ball ball : balls) {
    if (ball == null) {
      break;
    }
    if (ball.wasHit ( mouseX, mouseY)) {
      ball.destroyBall();
    }
  }
}


class Ball {


  float x, y;
  float diameter;
  float vx = 0;
  float vy = 0;
  int id;
  float lifespan;
  float radius;
  color circleColor;
  float xin;
  float yin;
  float din;
  int idin;
  Ball[] others;


  Ball(float xin, float yin, float din, int idin, Ball[] oin) {
    x = xin;
    y = yin;
    diameter = din;
    id = idin;
    others = oin;
    lifespan = random(2000.0 - 750.0) + 750;
    radius = diameter/2;
    circleColor =  color(random(255), random(255), random(255));
  }


  void collide() {
    for (int i = id + 1; i < numBalls; i++) {
      float dx = others[i].x - x;
      float dy = others[i].y - y;
      float distance = sqrt(dx*dx + dy*dy);
      float minDist = others[i].diameter/2 + diameter/2;
      if (distance < minDist) {
        float angle = atan2(dy, dx);
        float targetX = x + cos(angle) * minDist;
        float targetY = y + sin(angle) * minDist;
        float ax = (targetX - others[i].x) * spring;
        float ay = (targetY - others[i].y) * spring;
        vx -= ax;
        vy -= ay;
        others[i].vx += ax;
        others[i].vy += ay;
      }
    }
  }


  void move() {
    vy += gravity;
    x += vx;
    y += vy;
    lifespan -= 2.0;
    if (x + diameter/2 > width) {
      x = width - diameter/2;
      vx *= friction;
    } else if (x - diameter/2 < 0) {
      x = diameter/2;
      vx *= friction;
    }
    if (y + diameter/2 > height) {
      y = height - diameter/2;
      vy *= friction;
    } else if (y - diameter/2 < 0) {
      y = diameter/2;
      vy *= friction;
    }
    /* boolean isDead() {
     return (lifespan < 0.0);
     }*/
  }


  void display() {
    stroke(255, lifespan);
    fill(circleColor, lifespan);
    ellipse(x, y, diameter, diameter);
    textAlign(CENTER, CENTER);
    fill(200);
    textSize(50);
    text("Score = " + (score), 110, 10);
  }
  boolean wasHit(float ShotX, float ShotY) {
    if ((y +diameter/2 >= ShotY && y - diameter/2 <= ShotY) &&
      (x +diameter/2 >= ShotX && x - diameter/2 <= ShotX)) {
      return true;
    }
    return false;
  }
  void destroyBall() {
    lifespan = random(500.0 - 250.0) + 250;
    score++;
    x = random(width);
    y = random(height);
  }
}
Computer, programmieren, Java, Processing, Spiele und Gaming
Weitere Inhalte können nur Nutzer sehen, die bei uns eingeloggt sind.