So I have this line of code:
public static void main(String[] args) {
System.out.print("Enter a year: ");
int a = 1004; //a = 1004
System.out.print("Enter another year: ");
int b = 2020; //b = 2020
int min = a < b ? a : b;
int max = a < b ? b : a;
System.out.print("Output: ");
for (int i = min; i <= max; i++) {
if (i%4==0 && i%100 !=0) {
System.out.print(i + ", "); //Output: 1004, 1008, 1012, 1016, 2020,
}
}
}
So the code will print out: Output: 1004, 1008, 1012, 1016, 1020,
How do I remove the last comma and replace it with a dot ?