I want to know if it is possible to use an if statement inside of math.max. For example if you have an object like so:
public class Obj {
private int i;
private boolean b;
public void setInt(int newInt) {
this.i = newInt;
}
public void setBool(int newBool) {
this.b = newBool;
}
public String getInt() {
return this.i;
}
public String getIsTrue() {
return this.b;
}
}
After initializing 3 new objects and defining all values, is it possible to do something like this:
System.out.println(Math.max(if(obj1.getIsTrue()) {obj1.getInt()}, if (obj2.getIsTrue()) {obj2.getInt()}, if (obj3.getIsTrue()) {obj3.getInt()}));
I know that it can be done with an array and a for loop, so I'm not asking is it possible at all, just is it possible to nest if statements in this way.
Aucun commentaire:
Enregistrer un commentaire