James Meade
James Meade

Reputation: 1169

How to create a table data structure with array lists in Android Java

I am trying to create a table like data structure to hold three array lists associated with each other for an Android application. The first array list will hold index values, the second will hold an actual value and the third will be a flag to say whether the actual value has changed or not. Would anyone please be able to help me with any advice or tips to solve this problem? Thank you very much in advance.

Upvotes: 1

Views: 972

Answers (2)

Macrosoft-Dev
Macrosoft-Dev

Reputation: 2185

public class A{
 int index, ArrayList<B> list;
}

public class B{
 boolean valueChanged,String actualValue;
}

So in the end use this:

WeakHashMap<String, List<A>> hashMap;

Upvotes: 0

St&#233;phane Bruckert
St&#233;phane Bruckert

Reputation: 22903

Better use Map by placing a map into a map. This is a good way to hold 3 data in a row.

Map <Integer, HashMap<String, Boolean>> table = 
           new HashMap <Integer, HashMap<String, Boolean>>();

The inner Map contains the values: actual value and flag. The outer Map contains the index to access the inner map which contains the values.

Upvotes: 1

Related Questions