Java - Check if input is a positive integer, negative integer, natural number and so on.

后端 未结 6 1121
长情又很酷
长情又很酷 2020-12-29 20:53

Is there any in-built method in Java where you can find the user input\'s type whether it is positive, or negative and so on? The code below doesn\'t work. I am trying to fi

6条回答
  •  庸人自扰
    2020-12-29 21:43

    Use like below code.

    if(number >=0 ) {
                System.out.println("Number is natural and positive.");
    }
    

提交回复
热议问题