import
java.lang.reflect.Field;
public
class
GFG {
public
static
void
main(String[] args)
throws
NoSuchFieldException,
SecurityException,
IllegalArgumentException,
IllegalAccessException
{
User user =
new
User();
Field field
= User.
class
.getField(
"identificationByte"
);
byte
value = field.getByte(user);
System.out.println(
"Value of Byte Field"
+
" identificationByte is "
+ value);
field = User.
class
.getField(
"selectionByte"
);
value = field.getByte(user);
System.out.println(
"Value of Byte Field"
+
" selectionByte is "
+ value);
}
}
class
User {
public
static
byte
identificationByte =
'E'
;
public
static
byte
selectionByte =
121
;
public
static
byte
getIdentificationByte()
{
return
identificationByte;
}
public
static
void
setIdentificationByte(
byte
identificationByte)
{
User.identificationByte = identificationByte;
}
public
static
byte
getSelectionByte()
{
return
selectionByte;
}
public
static
void
setSelectionByte(
byte
selectionByte)
{
User.selectionByte = selectionByte;
}
}