The Attribute
class denotes an MBean attribute. The MBean server and other objects use this class to get and set the values of attributes. The Attribute
class is present in the javax.management.Attribute
package.
The getValue
method can be used to get the value of the attribute object.
public Object getValue()
This method doesn’t take any parameters.
The getValue
method returns the value of the Arrtribute
object.
The code below demonstrates how to use the getValue
method.
import javax.management.Attribute;class AttributeGetValueExample {public static void main( String args[] ) {Attribute attr = new Attribute("Website_Name", "Educative");System.out.println( "Attribute value is: " + attr.getValue());}}
In the code above:
In line 1, we import the Attribute
class.
In line 4, we create an Attribute
object with the name attr
. For this object, we set the attribute name as Website_Name
and the attribute value as Educative
.
In line 5, we call the getValue
method on the attr
object and print the returned value.