• 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

Return Array - Help...

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am at a total loss as to what I'm missing here. I've been asking the question, but nobody will tell me what the answer is, so I'm hoping I can get the answer here (and soon... )

I have a method loadData() that I need to return an array to my main() method. I need to figure out what type the return is so I can properly name it in my loadData() method.

Here's a lowdown of what I have:

public class myProject()
{
public static ??? loadData() - this is where I don't know what to use!
{
//here I have the data I'm loading and the last part of the load is to turn the data into an array, so here's my last line prior to return

Group [] groups = {g1, g2, g3, g4, g5, g6};
return groups;
}
}

HERE'S where I need to call the returned array in my project:

public static void main(String[] args)
{
Group [] groups = loadData();
}

Is this enough data for someone to tell me what I'm missing here? I know that the array works as I've been able to test.

Thanks,
Carie
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Carrie,

Welcome to JavaRanch!

It should just be

public static Group[] loadData()

Makes sense, right?
 
Carie Herrick
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, thank you, thank you!!!

I've been tearing my hair out for 2 days trying to figure it out.

How simple was that!!??

Thanks again,
Carie
 
See ya later boys, I think I'm in love. Oh wait, she's just a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic