Java List Odd Numbers

 

Program to List Odd Numbers in Java.

/**
 * Program to List Odd Numbers Java Example.
 * @author W3schools360
 */
public class ListOddNumberExample {
	static void listOddNumber(int limitNumber){
		//Print limit number.
		System.out.println("Odd numbers between 1 and " + 
                                                 limitNumber + ":");
        
		//Find odd numbers.
               for(int i=1; i <= limitNumber; i++){               
                  //Test odd number condition.
                  if( i
                    System.out.println(i);
                  }
               }
	}
	
	
	public static void main(String args[]){ 
		//method call 
		listOddNumber(60); 
	}
}

Output:

Odd numbers between 1 and 60: 
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
51
53
55
57
59