Lets say I have a class
public class Ttype{
private String type = "";
public Ttype(String type) {
this.type = type;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
and I have arraylist of this class
ArrayList<Ttype> type = new ArrayList<Ttype>();
I have added some elements to the arraylist
type.add( new new Ttype("Hello"));
type.add( new new Ttype("Bye"));
type.add( new new Ttype("Hi"));
I want to be able to return a string when I search for specefic string in the arraylist. What I mean by that is:
Ttype t = type.get("Hello"); //t will be set to "hello" if hello is in the arraylist.
How can I do that?