An example for both is the ArrayList class. It functions like an
array (and is actually implemented using one), but provides
precise control over where in the array you can access.
ArrayList<String> myList = new ArrayList<String>();
myList.add("hello"); // somehow the string "hello" gets added to
the ArrayList System.out.println(myList.get(0)); // somehow the
zeroth element inside myList gets extracted. No need to know
where in myList this is actually stored
System.out.println(myList.get(1)); //The get method has complete
control over where you can retrieve data from. The get method
generates an exception because there is one string in myList
even though the actual implementation could have a slot for a
second string