0

I would like to ask what is the difference between

ArrayListMultimap.create()

And

RowData = new ArrayList().

I know the first one is used for Multimaps and the latter is used for lists but I once used the ArrayListMultimap.create() in a code and it can return values like this:

{[Color, Fruit], [Pink,Orange]}

Whereas the latter returns:

[Color,Fruit,Pink,Orange]

I was expecting that RowData = new ArrayList() can return values the way ArrayListMultimap.create() does....

Please enlighten me.

4
  • 1
    It's hard to understand what you're asking. If you build a car, you won't get a truck. If you build a truck, you won't get a car. Creating an ArrayList will create an ArrayList, not a Multimap. I suggest you read the javadoc of ArrayListMultimap and ArrayList. Commented Oct 10, 2013 at 7:28
  • Yeah, I know that they are used for different purposes (ArrayList,Multimap). What I'd like to ask is can an ArrayList return value like this: [[Color,Fruit],[Pink,Orange]]. Is it possible? Or do i need to use something else to make it possible? Commented Oct 10, 2013 at 7:36
  • An ArrayList doesn't return anything. Its methods return something. It seems you want a list of lists. And yes, of course it's possible. Commented Oct 10, 2013 at 7:41
  • I think you hit it right when you said List of list. That's what I'd like to do actually, thanks for mentioning it. Commented Oct 10, 2013 at 8:46

1 Answer 1

1

ArrayList its just a simple List http://docs.oracle.com/javase/7/docs/api/java/util/List.html

and ArrayListMultimap is a Multimap http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Multimap.html implementation based on ArrayList.

Basically those two classes provides different api.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.