I'm new to Java and I've been trying to turn this Array list of Terms (Letters and Numbers) into a String, (unless its 1, in which case the program should ignore the element).
Is this the proper way to go about accomplishing this or should I use a different method?
My code is as follows:
public String display() {
for (int i = 0; i < terms.size(); i++) {
char p = terms.get(i);
if(Character.isDigit(p = 1)) {
continue;
} else if (Character.isDigit(p)) {
return String.valueOf(p);
} else {
return Character.toString(p);
}
}
p = display();
return display();
}
Note: I know this is wrong - I just need someone to point me in the right direction.
Input Example: {Term('C', 1),Term('O',2)} would give "CO2"
termsdefined? What is its specific type? Is it aListof generic type? If so, which type?