简体   繁体   中英

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM