-1

How to find if a number or fraction is an integer in Java?

I did some research before but struggle to apply them. I want to do something like this:

if (x is int){
   //commands
}
lealceldeiro
  • 12,596
  • 4
  • 38
  • 67
Skill HHY
  • 19
  • 3

1 Answers1

-1

You should use something like this:

if((x%1)==0){
//do stuff
}

This checks to see if the decimal part of the number is zero.

TMcSquared
  • 77
  • 13