将主类的输入存储到类方法中

时间:2015-11-17 21:48:28

标签: java

我试图将一个类的输入存储到一个单独的类方法中的数组中,但我不确定如何执行此操作。This is the class that is accepting the input that I want to store into the class method This is the class my class method.

1 个答案:

答案 0 :(得分:1)

您应该将数组创建为静态变量而不是局部变量。

public class State
{
   private static String[] info = new String[5];


   public static void store(State state) {
      info[0] = ...
   }

   ...
}

另一个更好的选择是将State创建为Concrete类而不是Static类,但是在走路之前应该抓取它:)