I'm getting an error and I don't know what the problem is

This keeps outputting an error on line 93 that says “illegal start of expression” about my “public void update() {…}”

I see no other issues and I don’t understand why I can’t use public void here when it’s used several other times in the code.

public void update(){

    if (keyH.upPressed == true){
      playerY -= playerSpeed;
    else if(keyH.downPressed == true){
      playerY += playerSpeed;
    else if (keyH.leftPressed == true){
      playerX -= playerSpeed;
    else if (keyH.rightPressed == true){
      playerX += playerSpeed;



Hey, @Potato welcome to the forums.

I think on line 92 it needs to be public void update instead of public update.

Thanks for the welcome. I double-checked to make sure it has the public void update and it’s in there but the error still shows up. It seems to have something to do with a try {…} and catch {…} thing I have in the code a bit earlier

In the very last line of code in your post, there’s a curly brace, then a normal bracket. That bracket might be the source of the error.

Also, not experienced in Java, but in most programming languages you would be able to do if (keyH.upPressed) (usually there’s no need to add == true if it’s already a boolean).

Corrected it but still getting the error, would it be helpful if I posted the full code?

Okay so I ended up changing my game loop to a delta loop as opposed to one that used sleep and now it’s working so I guess problem solved? Thanks for all the help :smiley:

Hey quick question, does is adding another one of the .java things like making another package? I’m following a tutorial but the guy is not using replit lol

From my limited Java knowledge, yes. Here’s a resource that may help: How to Create a Package in Java? - GeeksforGeeks