Check if a list of integers contains only odd numbers in Java

Java Program to print Odd and Even Numbers from an Array

We can print odd and even numbers from an array in java by getting remainder of each element and checking if it is divided by 2 or not. If it is divided by 2, it is even number otherwise it is odd number.

Test it Now

Output:

Odd Numbers: 1 5 3 Even Numbers: 2 6 2
Next TopicJava Programs


← prev next →

Java Program to Find the Number Occurring Odd Number of Times

Given an array of positive integers. All numbers occur even number of times except one number which occurs an odd number of times. Find the number in O(n) time & constant space.

Examples :

Input : arr = {1, 2, 3, 2, 3, 1, 3} Output : 3 Input : arr = {5, 7, 2, 7, 5, 2, 5} Output : 5

Write a java program to check if a list of integers contains only odd number. Please do it using parallel stream

Java Program to Check Even and Odd Number

In this tutorial, we will learn how to check whether the entered number is even or odd. Even numbers are the numbers that are divisible by 2 and the numbers that are not divisible by 2 are called odd numbers. Here, in this program, we will check whether the number is divisible by 2 or not. If divisible, then it is an even number, and if not then it is an odd number. But before moving further, if you are not familiar with the concept of the conditional statement in java, then do check the article on Conditional Statement.

Input: Enter the number: 6

Output: The entered number is even.