• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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: 79969
396
  • 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...
     
    You are HERE! The other map is obviously wrong. Better confirm with this tiny ad:
    Gift giving made easy with the permaculture playing cards
    https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply
      Bookmark Topic Watch Topic
    • New Topic