Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is class.forname() and how it will be useful ?

Answer Posted / pradip

class.forname() is used to create an instance of a class on
the basis of the name in string format instead of doing new
Class. One of its use is in cases where you have some
generic (common) logic to call methods of some classes just
on the basis of the names of the class and the method. The
example of reflection shown below uses the logic.

Eg:
performAction(String className, String methodName) {
Class class = Class.forName(className);
MethodUtils.invokeMethod(class.newInstance, methodName,
null);
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between linkedlist and arraylist.

1048


What is the range of the short type?

987


Explain naming conventions for packages?

1011


what is interface in java? Explain

946


what is the difference between Object Based Language and Object Oriented Language?

1017


Implementations of set interface?

991


What is the use of generics? When was it added to the Java development Kit?

996


What is a jit compiler?

1110


What is a blocking method in Java?

1205


What is runtime locatable code?

1405


Can we convert integer to string in java?

1037


What does split function do in java?

996


How garbage collection is done in java?

1028


What is the static block?

1051


What data type is string java?

947