Java 表达的开始是非法的?布鲁杰

Java 表达的开始是非法的?布鲁杰,java,Java,不知道为什么会发生这种情况,我尝试删除“public”,但仍然收到100万个其他错误 public class Script0 { public static void main() { int[] score = new int[ - 0]; public Keying(Display d) { d.f.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) {

不知道为什么会发生这种情况,我尝试删除“public”,但仍然收到100万个其他错误

public class Script0 {
    public static void main() {   
    int[] score = new int[ - 0];

   public Keying(Display d) {
   d.f.addKeyListener(new KeyAdapter() {
    public void keyPressed(KeyEvent e) {
        if (e.getKeyCode() == KeyEvent.VK_S) {
            score ++;
        }
        if (e.getKeyCode() == KeyEvent.VK_META) {
            score--;
        }
        }
    }
  }
 }
}

关闭
main
方法的括号,并尝试添加
score
数组的
length
,如下所示:

   public static void main(String[] args) {   
    int[] score = new int[some_length];
    }
  public void Keying(Display d) {
  ...
  public Script0() {
   ...
  }
并尝试添加一个返回值
Keying
方法,或像这样使用
void

   public static void main(String[] args) {   
    int[] score = new int[some_length];
    }
  public void Keying(Display d) {
  ...
  public Script0() {
   ...
  }
要在不使用字段的情况下创建构造函数,请执行以下操作:

   public static void main(String[] args) {   
    int[] score = new int[some_length];
    }
  public void Keying(Display d) {
  ...
  public Script0() {
   ...
  }

main
的签名错误。并且不能在
Script0
类的
main
方法中嵌入
Keying
构造函数。最后,长度为
-0
的数组并不是特别有用。这段代码有很多错误。与缩进一样,
main
方法中缺少参数,缺少
}
。还有
newint[-0]的目的是什么以及为什么该类的构造函数的名称与类本身的名称不同?在问任何问题之前,你应该考虑阅读基础教程。因为你有时不编译代码,所以有100万个错误。我相信你的代码中有很多错误。Idk,我是java新手,我的主要语言是Lua,所以我用尽可能少的知识把它们放在一起。java的特征是什么?此外,OP的构造函数属于另一个类。