문제

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);
}
}    
도움이 되었습니까?

해결책 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);
    }
}

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top