Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java check if number is even

if (number % 2 == 0) {
  // even number
} else {
  // odd number
}
Comment

check if number is odd java

if (num % 2 == 0)
{
	// even number
}
else
{
	// odd number
}
Comment

odd number in java

import java.util.Scanner;

public class Exam{
	public static void main(String[] args){
    
		Scanner scan = new Scanner(System.in);
        System.out.println("Enter number");
		int input = scan.nextInt();
		if(input % 2 != 0){
        	System.out.println(input + " is odd");
	      }
		else
			System.out.println(input + " is even");
	}
}	
Comment

odd numbers in Java

n = 10;
for (int i=0; i<=10; i++){
  System.out.println(2*n+1);
}
Comment

PREVIOUS NEXT
Code Example
Java :: java stream get list of one field 
Java :: set password visible in android 
Java :: java array to collection 
Java :: how to print hello world java 
Java :: string to float java 
Java :: java format use same value multiple times 
Java :: nested for each loop java 
Java :: define a list java 
Java :: get input in java using joptionpane 
Java :: array contains java 
Java :: android list[index] 
Java :: thread 
Java :: java stream distinct by atribute 
Java :: max of an array java 
Java :: from string to double java 
Java :: java insert char in string at index 
Java :: print values of bst java 
Java :: java check if number is in range 
Java :: java copy file 
Java :: timestamp to date java 
Java :: java break 2 for loops 
Java :: how to modify string in java 
Java :: number of digits java 
Java :: viewpager androidx dependencies 
Java :: how to remove null values in java 
Java :: android kill other app programmatically by package 
Java :: volley library 
Java :: java initialize string array 
Java :: threads array java 
Java :: java random int between 2 numbers 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =