Java: Find odd and even numbers




public class JCollection {
    public static void main(String[] args){
        // Find odd and even numbers;
        int num = 10;
        boolean state = num%2!=2 ? true:false;
        if(state){
            System.out.println(num+" Even Number");
        } else {
            System.out.println(num+" Odd Number");
        }
    }
}


Share on Google Plus

About Ram Pukar

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment

0 comments:

Post a Comment