• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

object creation

 
Ranch Hand
Posts: 180
Netbeans IDE Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to create an instance of a class implicitly ?also explain it.
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Ashok Pradhan
Ranch Hand
Posts: 180
Netbeans IDE Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
No holds barred. And no bars holed. Except this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic