[英]How can I access to a public final static list declared into an utility class from another class in a Java application?
I have the following doubt.我有以下疑问。 Into a Java application I have an utility class like this:在 Java 应用程序中,我有一个像这样的实用程序类:
public class CodUtility {
/* TIPOLOGIA PROGETTO */
public static final String CODICE_PROGETTO_WIFI = "W";
public static final String CODICE_PROGETTO_LIM = "L";
public static final String CODICE_PROGETTO_ALTRO = "A";
public static final String CODICE_PROGETTO_CLASSI20 = "2";
public static final String CODICE_PROGETTO_SCUOLA20 = "S";
public static final String CODICE_PROGETTO_CSD = "C";
public static final LinkedHashMap<String, String> hashMapDescrizioneTipologiaProgetto = new LinkedHashMap<String, String>();
static {
hashMapDescrizioneTipologiaProgetto.put(CODICE_PROGETTO_WIFI, "WIFI");
hashMapDescrizioneTipologiaProgetto.put(CODICE_PROGETTO_LIM, "LIM");
hashMapDescrizioneTipologiaProgetto.put(CODICE_PROGETTO_ALTRO, "Altro");
hashMapDescrizioneTipologiaProgetto.put(CODICE_PROGETTO_CLASSI20, "Classi 2.0");
hashMapDescrizioneTipologiaProgetto.put(CODICE_PROGETTO_SCUOLA20, "Scuola 2.0");
hashMapDescrizioneTipologiaProgetto.put(CODICE_PROGETTO_CSD, "CSD");
}
public static final List<String> listaCodiciTipologiaProgetto = new ArrayList<>(hashMapDescrizioneTipologiaProgetto.keySet());
/* FINE TIPOLOGIA PROGETTO */
}
This class define this public final static list:这个类定义了这个公共最终静态列表:
public static final List<String> listaCodiciTipologiaProgetto = new ArrayList<>(hashMapDescrizioneTipologiaProgetto.keySet());
Now my doubt is: ho can I retrieve it from another class.现在我的疑问是:我可以从另一个类中检索它吗? I need to retrieve this list from another class and access to it.我需要从另一个类中检索此列表并访问它。
How can I do this operation?我怎样才能做这个手术?
Are you just trying to get the list from another object?你只是想从另一个对象中获取列表吗?
CodUtility.listaCodiciTipologiaProgetto;
Will return the list.将返回列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.