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(
"identificationChar"
);
char
value = field.getChar(user);
System.out.println(
"Value of Char Field"
+
" identificationChar is "
+ value);
field = User.
class
.getField(
"selectionChar"
);
value = field.getChar(user);
System.out.println(
"Value of Char Field"
+
" selectionChar is "
+ value);
}
}
class
User {
public
static
char
identificationChar =
'E'
;
public
static
char
selectionChar =
'A'
;
public
static
String name =
"Aman"
;
public
static
char
getIdentificationChar()
{
return
identificationChar;
}
public
static
void
setIdentificationChar(
char
identificationChar)
{
User.identificationChar = identificationChar;
}
public
static
char
getSelectionChar()
{
return
selectionChar;
}
public
static
void
setSelectionChar(
char
selectionChar)
{
User.selectionChar = selectionChar;
}
public
static
String getName()
{
return
name;
}
public
static
void
setName(String name)
{
User.name = name;
}
}