wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes object creation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "object creation" Watch "object creation" New topic
Author

object creation

Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 180

How to create an instance of a class implicitly ?also explain it.
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282


"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 180

thanks

But i think you are creating the object explicitly because you create the object using new operator.There are three ways to create object explicitly
that are:-by with the "new" operator,by invoking newInstance() on a Class object and by invoking clone() in an exiting object.

Reference:"Inside the Java Virtual Machine"
Bill Venners
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
Originally posted by Ashok Pradhan:
thanks

But i think you are creating the object explicitly because you create the object using new operator.There are three ways to create object explicitly
that are:-by with the "new" operator,by invoking newInstance() on a Class object and by invoking clone() in an exiting object.

Reference:"Inside the Java Virtual Machine"
Bill Venners


If we can bear in mind that this is a discussion in a beginner area and that others will provide critique that may not align with what I am using as my approach, your citation is productive in that there is some study to be done before isolation ofcreate an instance of a class implicitly can be disentangled from other issues.

When you say implict, there is a keyword which you will hear soon enough: static and the implicit part of object creation is that if you do not declare a variable static, then it is implicit that the variable is what is called an instance variable.

Thus, from above:

if added to the above code now gives you ( a java author generally ) three ints or one could write:

in which what was a variable now is a class ( object ) so what is the difference ?

well for one thing, to get firstInt to exist, you have to call the new operator somewhere, else it was called somewhere else and assigning an integer to firstInt requires the calling of the new operator somewhere.

In addition to that, you have to create an instance of FirstObject ( somewhere ) with the new operator, but there is no keywork instance, that is nomenclature used in speaking of implied states of the program at some point in the code.

Now to get an instance of the FirstObject, I used what is called main() - the reason I did that was so that you ( or an observer of our conversation ) can get a FirstObject to deliver some useable work from the physical machine.

Using: Inside the Java Virtual Machine as a beginner text will involve us in discussions like this - if you wish to continue this discussion further I will only do so if the moderator moves it to the intermediate forum due to failures trying to work at this depth with beginners. You may move this post yourself by simple reposting with How to create an instance of a class implicitly ? as the title of a post in the intermediate forum - you will get plenty of help if I do not find it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: object creation