System.out.print()输出不换行
System.out.println()输出换行
示例:
import java.util.Scanner;
public class NumbersInRange {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
// Get L and R from the input
int L = s.nextInt();
int R = s.nextInt();
// Write here the logic to print all integers between L and R
for(int i = L;i <= R;i++){
System.out.print(i+" ");
}
s.close();
}
}
执行结果:
Input:
L = 5, R = 10
Output:
5 6 7 8 9 10