An MBA in finance imparts and improves management aptitude, inventive ability, critical thinking ability, and so forth. It offers a real-time experience that fabricates a staunch career foundation for students and working professionals. It helps them to thoroughly understand the financial sector.
import java.util.*; public class MyClass { public static void main(String args[]) { MyClass hw = new MyClass(); List<Integer> list = new ArrayList<Integer>(); //Adding elements in the List list.add(11); list.add(13); list.add(15); list.add(3); if(hw.onlyOddNumbers(list)) System.out.println("List contain only odd number"); } public static boolean onlyOddNumbers(List<Integer> list) { for (int i : list) { if (i % 2 == 0) return false; } return true; } }
Output.
List contain only odd number
Liked By
Write Answer
Check if a List of integers contains only odd numbers?
Join MindStick Community
You have need login or register for voting of answers or question.
Mukul Goenka
17-Nov-2021Output.
List contain only odd number