Search code examples
javastaticfinal

illegal modifier for parameter


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);
}
}    

Solution

  • 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);
        }
    }