The Attribute
class denotes an MBean attribute. The MBean server and other objects use this class to get and set attributes values.
The Attribute
class is present in the javax.management.Attribute
package.
getName
method of the Attribute
class?The getName
method can be used to get the name of the attribute object.
public String getName()
This method doesn’t take an argument.
This method returns a string representing the key of the Attribute
object.
The code below shows how to use the getName
method.
import javax.management.Attribute;class AttributeGetNameExample {public static void main( String args[] ) {Attribute attr = new Attribute("Website_Name", "Educative");System.out.println( "Attribute name is: " + attr.getName());}}
In the code above:
Attribute
class.import javax.management.Attribute
Attribute
object with the name attr
. For this object, we set the attribute name as Website_Name
and the attribute value as Educative
.Attribute attr = new Attribute("Website_Name", "Educative");
getName
method on the attr
object and printed the value returned.attr.getName(); //Website_Name