I am trying to test for am or pm in a if else statement..
if(am){
//Do something
else{
//Do something else
Ive tried
int am = cld.get(Calendar.AM_PM);
but the if else
wont take it as a parameter to test. Maybe because its not boolean.
How would i go about testing this?
You’re correct that the if-else won’t accept it because it is not boolean.
Calendar.AM_PMonly ever holds the value0or1. A language like C would accept 0 or 1 as boolean; Java won’t.You want to do something more like this: