• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

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: 76825
366
  • 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...
     
    expectation is the root of all heartache - shakespeare. tiny ad:
    the value of filler advertising in 2021
    https://coderanch.com/t/730886/filler-advertising
    reply
      Bookmark Topic Watch Topic
    • New Topic