集册 Java实例教程 查找并列出介于1和任何给定数字之间的偶数

查找并列出介于1和任何给定数字之间的偶数

欢马劈雪     最近更新时间:2020-01-02 10:19:05

535
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
查找并列出介于1和任何给定数字之间的偶数
//nowjava 提 供

public class Main {

        public static void main(String[] args) {

                int limit = 50;

                System.out.println("Printing Even numbers between 1 and " + limit);

                for(int i=1; i <= limit; i++){

                        if( i % 2 == 0){

                                System.out.print(i + " ");

                        }

                }

        }

}

 
 /**
 来 自 时 代 J a v a 公 众 号
 **/