Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class.newInstance() Vs object.clone()

 
kri shan
Ranch Hand
Posts: 1472
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class.newInstance() creates new instance dynamically and object.clone() creates the replica object. What is the difference(both are used for creating instances)?
 
Maneesh Godbole
Saloon Keeper
Posts: 11092
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you fully read the API docs for Object#clone() ? What would happen if you invoke the clone() on an object?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic