Results 1 to 2 of 2
  1. #1
    Problemer is offline Member
    Join Date
    Sep 2012
    Rep Power

    Default Return an object.

    Hello ,

    In a method i have created an object , i have stored it in an ArrayList so i can return it to the caller of the method. And it works perfectly.

    My question since it is only one object , do i need to store it in an ArrayList to be able to return it or can i skip the arraylist part somehow?

    Best Regards Rickard.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power

    Default Re: Return an object.

    You can declare your method to return a reference to any sort of thing, not just a list. Try it and see what happens.

Similar Threads

  1. Method to return object
    By Collider in forum New To Java
    Replies: 9
    Last Post: 05-02-2012, 03:35 PM
  2. About the method which return an object
    By nihirus in forum New To Java
    Replies: 6
    Last Post: 02-22-2012, 12:10 AM
  3. Return an object to use in another method
    By TidusSolan in forum New To Java
    Replies: 3
    Last Post: 03-19-2009, 08:00 PM
  4. How I can return an object?
    By CFW in forum New To Java
    Replies: 4
    Last Post: 01-14-2009, 10:54 AM
  5. how to return an object from an arraylist
    By elizabeth in forum New To Java
    Replies: 1
    Last Post: 07-30-2007, 06:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts