• 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

Different ways to create Objects

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are the different ways to create Objects in Java? Could anyone help on this?
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why have you posted this as an "advanced" question?

As far as I can remember you can get an Object by:-
  • Invoking its constructor with the new operator/keyword [Foo myFoo; . . . myFoo = new Foo();]
  • Retrieve an object which has been previously stored (Serialized) or transmitted (also Serialized).
  • Retrieve a previously stored object from a bean.
  • Use the Class class. [Foo myFoo; . . . myFoo = (Foo) Class.forName("mypackage.Foo").getInstance();]

  • There may be more.
    Please check the spelling of the methods carefully with the API website before you use any of these suggestions.

    CR
     
    Java Cowboy
    Posts: 16084
    88
    Android Scala IntelliJ IDE Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Try doing a search in the forums. Your question has been asked before. (Is this some kind of standard question for interviews or an exam somewhere?).
    [ March 07, 2007: Message edited by: Jesper Young ]
     
    Bartender
    Posts: 10336
    Hibernate Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Not an advanced question. Moving...
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic