-4

ArrayList testdata_1 = new ArrayList<>();

    for (int i = 0; i < testdata_1.size(); i++) {

        System.out.println(testdata_1.get(i));
    }

My output is

[]
[[Username,Password], [user_1, Test@100]]

I want to delete the first blank value ,iterate the arraylist, identify the key as username,fetch the value "user_1" and assign to a local string variable "username"

Datatable | Username | user_1 | | Password | Test@100 |

List> data = new ArrayList<>(); if(step.getRows()!=null) step.getRows().forEach(row -> data.add(row.getCells()));

novice
  • 43
  • 11
  • 1
    So what is the problem? Just do it. – mentallurg Jun 09 '18 at 22:32
  • Post the code for your objects in `testdata_1`. But okay, we could work with their `toString()` output if you insist – John Jun 09 '18 at 22:33
  • 1
    Possible duplicate of [How to avoid java.util.ConcurrentModificationException when iterating through and removing elements from an ArrayList](https://stackoverflow.com/questions/8104692/how-to-avoid-java-util-concurrentmodificationexception-when-iterating-through-an) – Tibrogargan Jun 09 '18 at 22:34
  • Can you show us your attempt to solve this problem? (And can you explain how he data structure got to be in that strange state? If it was by accident, ideally you should fix the accident. If it was by design .... why?) – Stephen C Jun 09 '18 at 22:59
  • I have a data table | Username | user_1 | | Password | Test@100 | which i read and store it in List> data = new ArrayList<>(); if(step.getRows()!=null) step.getRows().forEach(row -> data.add(row.getCells())); Is there a better way to read the data table and store it in the format i require – novice Jun 09 '18 at 23:14
  • @Tibrogargan - I tried the solution in that link and it did not work for me – novice Jun 09 '18 at 23:17

1 Answers1

0

Resolved. Used data encapsulation to resolve this

novice
  • 43
  • 11