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

    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
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    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, 04:35 PM
  2. About the method which return an object
    By nihirus in forum New To Java
    Replies: 6
    Last Post: 02-22-2012, 01: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, 09:00 PM
  4. How I can return an object?
    By CFW in forum New To Java
    Replies: 4
    Last Post: 01-14-2009, 11: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, 07: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
  •