package day05;
import java.util.Scanner;
/*
* 写一个方法,传递一个整数(大于1),在控制台打印1到该数据的值
* */
public class Method5 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("输入数值:");
int i = sc.nextInt();
print(i);
}
public static void print(int i){
for (int x = 1; x <= i; x++) {
System.out.println(x);
}
}
}
|
|