Question

I just begin to program in adt and decide to go for libgdx, the problem is that when I try to put a version in my program it shows me the error:

illegal modifier for parameter VERSION; only final is permitted

Here is the code with the problem:

package com.me.mygdxgame;


import com.badlogic.gdx.Version;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;

public class Main {

public static void main(String[] args) {
    public final static String VERSION= "0.0.1";
    LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
    cfg.title = "my-gdx-pong-game";
    cfg.resizable= false;
    cfg.width = 480;
    cfg.height = 320;

    new LwjglApplication(new MyGdxGame(), cfg);
}
}    
Was it helpful?

Solution 2

You probably wanted to declare VERSION outside of the main method like this...

package com.me.mygdxgame;


import com.badlogic.gdx.Version;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;

public class Main {
    public final static String VERSION= "0.0.1";

    public static void main(String[] args) {
        LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
        cfg.title = "my-gdx-pong-game";
        cfg.resizable= false;
        cfg.width = 480;
        cfg.height = 320;

        new LwjglApplication(new MyGdxGame(), cfg);
    }
}

OTHER TIPS

You are using public and static keywords for a variable declared at the method. They are allowed only for classes/methods/interfaces/annotations/class members, but not for local variables.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top