The following is the program segment of a JAVA program: amount = 100 while (i>0) { System.out.println(amount); amount = amount - 1; } Rewrite the above using GOTO.
Advertisements
Question
The following is the program segment of a JAVA program:
amount = 100
while (i>0)
{
System.out.println(amount);
amount = amount - 1;
}
Rewrite the above using GOTO.
Short Answer
Advertisements
Solution
In Java, the goto statement is not supported. Although goto is a reserved keyword, it cannot be used as a jumping statement.
Therefore, the given program segment cannot be rewritten using goto in Java. Java provides alternative control statements such as break, continue, and labelled statements.
shaalaa.com
Is there an error in this question or solution?
