开发者

if/then conditional statements using ints

开发者 https://www.devze.com 2023-01-25 19:26 出处:网络
Super easy, I am sure - but in conditional if/then statements using droid, how do I go about using them with integers, ie:

Super easy, I am sure - but in conditional if/then statements using droid, how do I go about using them with integers, ie:

int currentHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);

public void getResult(int currentHour, Intent intent) 开发者_开发百科{
    if (currentHour < 14) then:
        //do something
}

I know this isn't the right way to do it, but I am having a brain fart as to comparing ints...thanks!


I strongly suspect you're looking for

if (currentHour < 14) { 
    // do something
}

This is common to virtually all C-syntax languages.


public void getResult(int currentHour, Intent intent) {

  if (currentHour < 14){
    //do something
  } else {
    //do something else
  }

}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号