Add the values on ArrayList in Android [closed]

After getting value from intent: ArrayList<String> arrayList = new ArrayList<String>(); valueaddlist = (Button) findViewById(R.id.valueaddlist); valueaddlist.setOnClickListener(new OnClickListener() { public void onClick(View v){ arrayList.add(product_id); arrayList.add(product_title); arrayList.add(product_image); arrayList.add(product_price); arrayList.add(product_desc); } valuedisplaylist = (Button) findViewById(R.id.valuedisplaylist); valuedisplaylist.setOnClickListener(new OnClickListener() { public void onClick(View v){ Intent intent = new Intent(this,AddedListProducts.class); intent.putStringArrayListExtra(“arrayList”, (ArrayList<String>) arrayList); startActivity(intent); } May be this will help you. In … Read more

How to convert ArrayList to String[][]?

String[][] strings2 = convertStringArrayList(listOfStringLists); Convert ArrayList<ArrayList<String>> to String[][] method: private String[][] convertStringArrayList( ArrayList<ArrayList<String>> listOfStringLists ) { String[][] stringGroups = new String[listOfStringLists.size()][]; for ( int i=0; i< listOfStringLists.size(); i++ ) { ArrayList<String> stringArray = listOfStringLists.get(i); String[] stringsChildren = Arrays.copyOf(stringArray.toArray(), stringArray.toArray().length, String[].class); stringGroups[i] = stringsChildren; } return stringGroups; }

Removing duplicates from arraylist using set

Find the intersection Find the union Subtract the intersection from the union Code: public static void main(String[] args) { Set<Integer> set1 = new HashSet<Integer>(Arrays.asList(1, 2, 3, 4, 5)); Set<Integer> set2 = new HashSet<Integer>(Arrays.asList(1, 3, 6, 7)); Set<Integer> intersection = new HashSet<Integer>(set1); intersection.retainAll(set2); // set1 is now the union of set1 and set2 set1.addAll(set2); // set1 … Read more