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 of
create 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.