Monthly Archives: May 2016
Using reflection to call methods of a Java class – A simple use case
We can use reflection feature of Java to invoke methods of a Java class. Suppose we have a class Employee, with getter methods for fields – name, age sex, salary, city. A user may want to send an array of property names to a method and based on the input…
Reading a File from same package in a Java Class
Sometimes we may need to read data from a file in a Java class and this file lies in the same package as that of the class. Different Java classes may need to read data from a file lying in their own package. If all the files in different packages…