:) Can anyone tell me what INSTANTIATE means in a java program, with a possible Example.
ty
gail
Printable View
:) Can anyone tell me what INSTANTIATE means in a java program, with a possible Example.
ty
gail
Here's another forum somebody already explained it in always check google first here's the link http://forums.dreamincode.net/showtopic13782.htm
Insantiate means 'to create an instance of'. In object oriented programming, objects are defined by classes, a class being a 'blueprint' of an object.
For example, think about chocolate chip cookies. You make them by following a recipe. The recipe defines what it is to 'be' a chocolate chip cookie. You can't use it to make oatmeal cookies or peanutbutter cookies, only chocolate chip cookies, because chocolate chip cookies have attributes that are unique to their type.
Instantiating a chocolate chip cookie means to create a single cookie by using the recipe (class). So, if I created a class called 'CCCookie', I would instantiate a 'CCCookie' with code like this:
CCCookie myCookie = new CCCookie();
I could make another one:
CCCookie yourCookie = new CCCookie();
I have now instantiated two of them...but they are totally independent of each other. If I were to execute the code
myCookie.eat();
It would not affect yourCookie in any way, because they are separate instances of the CCCookie class.
Hope this helps.