0
whats the problem?
public class Main { public static void main(String[] args) { for (int i = 1; i < 3 + 1; i++){ System.out.printf ("%d/%d/%d" , i); } } }
5 Respostas
+ 1
What about
System.out.print(i+"/");
Then just remove the last /
for(int i = 0; i < 10 ; i++) {
if(i == 9) {
System.out.print(i);
} else{
System.out.print(i+"/");
}
}
0
Atleast the print statement is invalid, you're trying to say to the function to print 3 numbers, even though there is just 1.
0
Whenever you write a question, please mention what you were trying to achieve and where is the problem exactly. This is still fine but for large codes, what's the problem is not going to help if you do not mention anything in specific.
So what were you expecting?
0
Avinesh I'm expecting that the output will be 1/2/3 . Because I did the for loop to count from 1 to 3...
0
System.out.printf("%d/" , i);
But this will give 1/2/3/. You can put an if else just like HNNX 🐿 has mentioned to get rid of the last /.