![]() |
VOOZH | about |
The setShort() method of java.lang.reflect.Field is used to set the value of a field as a short on the specified object. When you need to set the value of a field of an object as short then you can use this method to set value over an Object. Syntax:
public void setShort(Object obj, short s) throws IllegalArgumentException, IllegalAccessException
Parameters: This method accepts two parameters:
Return: This method returns nothing.
Exception: This method throws the following Exception:
Below programs illustrate setShort() method:
Program 1:
Value of uniqueNo before applying setShort is 239 Value of uniqueNo after applying setShort is 134
Program 2:
Value after applying setShort is 5366
References: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Field.html#setShort-java.lang.Object-short-