Here my code

public static String modele;
   
   public static String supplier;
   
   public static int height = 180;

   public static final String[] COLORS = { "RED", "BLUE", "GOLD",
         "ORANGE", "PURPLE", "PINK", "NONE" };
        
    public static String description;
    
    public static boolean withSnow = false;
    
    public static boolean sale = false;
    
    public static int numIdentification;

    //constructor

    public Tree (String modele, String supplier, String description, int height, int typeColors, boolean sale, boolean withSnow){

        //////////////////////////////////////
        // a completer selon les directives //
        //////////////////////////////////////
        this.modele = modele;
        this.supplier = fournisseur;
        this.description = description;
        this.height = hauteur;
        this.sale = sale;
        this.withSnow = withSnow;
        numIdentification = numIdentification + 1; 



    }

Here my question

when i created my Tree with this constructor

let say i created my object i pass those values

Tree("tree1","supplier1","firstDescrip",190,2,true,true);

the variable typeColors in my constructor i assign number 2

how i determined that 2 = "BLUE" in my array name COLORS when i create the object.

I want to call it with a function Tree.getColors to get the value.

I just can't figured out how.... any help would be appreciated.

Sorry if my english its not good.

i think i found a solution myself

i create another variable naming modeleColors

and when creating object

i assign modeleColors = COLORS[typeColors];

not sure if the right way to do it.

Bonjour. C'est bon, mais vous avez vos variables "static", c'est a dire que il-y-a une value pour tous les instances. Mauvais idée.
Votre vache espagnole
J

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.