• Post Reply Bookmark Topic Watch Topic
  • New Topic

question two instance method  RSS feed

 
zb cong
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello:
see my code below:

package test;
public class Obj {
public Obj() {
System.out.println("i am the object!");
}
}

this is a simple class,i want to instantiate it,i find that both of the following two methods work,but i don't know the difference between them,that is,when i use which one method?
client.getClass().getClassLoader().loadClass("test.Obj").newInstance();
and
Beans.instantiate(client.getClass().getClassLoader(), "test.Obj");

who can answer me?
thank you!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!