I have been wondering how and/or if you can use a char
for equations. And please don't comment "why wud u want to do that"?
Example:
public static void main(String... args) {
char equalitySign = '<';
boolean check = 5 equalitySign 10;
}
I know the above code won't run(obvisously), but I was wondering if there was a similar way of doing so. Or would I just have to use if/switch statements?
Example 2:
public static void main(String... args) {
char equalitySign = '<';
boolean check;
if (equalitySign == '<' + '=') {
check = 5 <= 10;
System.out.println("is 5 less than or equal to 10, " + check);
} else if (equalitySign == '<') {
check = 5 < 10;
System.out.println("5 is less than 10, " + check);
} else if (equalitySign == '>') {
check = 5 > 10;
System.out.println("5 is greater than 10, " + check);
}
}
Thanks!