Arrays constants can only be used in initializers error

前端 未结 5 1876
谎友^
谎友^ 2020-11-30 10:19

Consider:

public proj 3 {

    static string [][]Item;

    public static void main(String [] args){

        Item[][] = {
             {\"BH,\" , \"Backhoe,         


        
5条回答
  •  孤独总比滥情好
    2020-11-30 11:08

    I'm not 100% sure if I got correctly what you mean, but you can reference static class members by fully qualifying it.

    public class MyClass {
      // static class member
      public static String myStaticArray;
    
      // non-static class method
      public void myMethod() {
        MyClass.myStaticArray = {...}; // do stuff
      }
    }
    

提交回复
热议问题