• Post Reply Bookmark Topic Watch Topic
  • New Topic

what mean is instantiate the class?  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all.. i am confuse with the meaning for instantiate the class?

when i
Test test1 = new Test();

am i instantiate the Test class into test1 ?


please advise..
 
Ranch Hand
Posts: 156
Android Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When you are doing "new Test()" creating an instance of the class Test. i.e. instantiating the class.

test1 is a reference variable of the type Test.
by doing :
Test test1 = new Test();
you are storing the reference of the Test class instance in the variable test1.

So that you could use if further to invoke methods or access member variables.

Regards,
Priety.
 
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instantiating a class simply means you are creating object of it !
 
Adam Lim
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, i am understand now.

thank you
 
Marshal
Posts: 59146
180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and welcome to JavaRanch
 
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!