How to return the declaration of an attribute in a JLabel?

0

I'm a beginner in programming, my question is:
  - I created a public static final double Preco_Gasolina = 3.85 attribute in a class A.
 - I want to return the value of Preco_Gasolina = 3.85 in a JLabel in class B.

This is possible, how do I?

    
asked by anonymous 17.04.2016 / 22:53

1 answer

2

In class B, just do the following:

myJLabel.setText(String.valueOf(A.Preco_Gasolina));

Because your attribute is static and public, you just need to refer to class A and call it directly, doing the conversion from double to String , using valueOf() .     

17.04.2016 / 23:04