I simply want to get the last value in an ArrayList using reflection. Typically this is achieved by doing:
String s = ArrayList.get(ArrayList.size()-1);
I've tried doing:
String s = Object.get(ClassInstance, Object.get(ClassInstance, ArrayList.size()-1));
Obviously this isn't the correct syntax. What would the correct syntax be to achieve this?
EDIT:
The reason for trying to do this is because I am unit testing my code and the ArrayList located inside the class I am testing is private. One of my boolean methods takes a parameter and I wanted to test it using the last value in the ArrayList (I don't know the value as it is randomly generated, but the value should always return true). Any solutions for this problem are much appreciated.