Consider the following Java code fragment:
public class While { public void loop() { int x = 0; while(1) { System.out.println("x plus one is" +(x+1)); } } }
While is a keyword right ? so how can we use it as class name ? I think 1 & 6 line no. have errors.
Sorry! my mistake I wasn't aware of this concept in java : yes only line no. 6 will give error.. please check the below link
https://stackoverflow.com/questions/30491035/can-java-class-files-use-reserved-keywords-as-names
@ Divya Bharti
The class name is While not while keyword it does not treat it as a keyword as java is case sensitive
64.3k questions
77.9k answers
244k comments
80.0k users