function with name of Class as parameter
in
Programming Questions
•
1 month ago
Hi,
I'm searching to make a function who has 3 parameters : String, ArrayList, Class ;
the goal of it is to search inside the ArrayList if an instance has the name specified in String parameter.
I've got an error : the Class parameter don't replace the Class name inside the function.
thanks a lot.
- IntDict isNAMEinsideCLASS(String name, ArrayList itemList, Class theClass) {
- IntDict toReturn = new IntDict();
- int nmbInequality = 0;
- for (int i= 0; i<itemList.size(); i++) {
- theClass item = itemList.get(i);
- if (item.name.equals(name)) {
- toReturn.set("true", i);
- }
- else {
- nmbInequality+=1;
- }
- }
- if(nmbInequality == itemList.size()){
- toReturn.set("false", -1);
- }
- return toReturn;
- }
1