public class RecentlyUsedList - Jfokus
public class RecentlyUsedList - Jfokus
public class RecentlyUsedList - Jfokus
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>public</strong> <strong>class</strong> <strong>RecentlyUsedList</strong><br />
{<br />
<strong>public</strong> void add(String newItem)<br />
{<br />
list.remove(newItem);<br />
list.add(0, newItem);<br />
}<br />
<strong>public</strong> ArrayList getList()<br />
{<br />
return list;<br />
}<br />
<strong>public</strong> void setList(ArrayList newList)<br />
{<br />
list = newList;<br />
}<br />
private ArrayList list;<br />
}<br />
<strong>RecentlyUsedList</strong> list = new <strong>RecentlyUsedList</strong>();<br />
list.setList(new ArrayList());<br />
list.add("Hello, World!");<br />
assert list.getList().size() == 1;<br />
list.getList().clear();<br />
assert list.getList().isEmpty();