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

What do you mean by singleton class in java?

856


What is the maximum size of a string in java?

1004


Why do we need strings in java?

942


What does flagged out mean?

1006


How thread scheduler schedule the task?

1007


Why enumeration is faster than iterator?

893


What are loops in java? What are three types of loops?

986


Is singleton set an interval?

901


What is generics in java interview questions?

1004


Explain the difference between jvm and jre?

975


Is java a compiler?

921


Explain illegalmonitorstateexception and when it will be thrown?

1040


Why do we create threads in java?

1149


What are different types of expressions?

1047


what do you mean by classloader in java?

978