• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Object within an Object - URGENT NEED

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I need to create an ArrayList or HasMap in a class which stores objects in it.
For example:
class A{
String A;
String B;
ArrayList array = new ArrayList();
public String getStringA(){
...}
public ArrayList getTest(){
return ArrayList;
}
But the problem I have is I need this Array List to hold objects.
In other terms, the ArrayList should be hold an Object containing 3 Strings.
Can i create an Object within a class not by instantiating.
Hope I am clear with my question. I need a urgent response. Please respond ASAP.
Thanks

This array list
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might use another collection to hold the three strings.

Or you might create your own class to hold the three strings. I'd recommend that if the three strings together make up some meaningful thing, like First Middle Last make up Name. And if they don't make up something meaningful, I'd worry about the design!
 
Plym Guy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Stan
 
Sheriff
Posts: 3036
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Stan James:



Good one Stan!
 
reply
    Bookmark Topic Watch Topic
  • New Topic