Interesting
Redeclaring a Variable in the Initialization Block resulting in the compiler error because of a duplicate variable declaration
int i = 0;
for(int i = 4; i < 5; i++) // DOES NOT COMPIL
1-5 is the correct,
print only when x is a impar number => result can be 1-5 and 3-3 but 3-3 so no match with the for condition (x<y) so breack loop and print only 1-5
public class Tester {
public static void main(String[] args) {
int x = 0, y = 6;
for (; x < y; x++, y--) {
if (x % 2 == 0) {
continue;
}
System.out.println(x + "-" + y);
}
}
}
Result: 1-5 , choose C.
b is correct:
ublic class Principal {
public static void main(String[] args) {
int x = 0, y = 6;
for (; x < y; x++, y--) {
System.out.println(x + "-" + y);
}
}
}
0-6
1-5
2-4
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Taggert
2 months, 2 weeks agoASPushkin
3 months, 1 week agod7bb0b2
1 year agojames2033
1 year, 2 months agoqulyt
1 year, 5 months agogopu_azure32
1 year, 6 months agoStavok
1 year, 7 months agoJGR_77
1 year, 9 months agoJGR_77
1 year, 9 months agod7bb0b2
1 year agokavithaprasanth
1 year, 9 months agoGuru_01
1 year, 11 months agoAnkit1010
1 year, 11 months agoUcefSoft
2 years, 1 month ago