In: Computer Science
I encountered this error in unit 5 game zone assignment 4 what do i need to do?
TwoDice2.java:31: error: reached end of file while parsing
}
^
This error most likely occurs If there was a missing Closing Brace( } ) of a corresponding Opening Brace( { )
For example:
class Example {
public static void main(String[] args) {
while(....) {
if(...) {
.....
.....
.....
}
}
}
The above program will result in the error: reached end of
file while parsing }
Reason:
Observe that for 'if' statement there was a opening brace({) but there is not corresponding closing brace (})
_________________________________________________________________________________________________________________
So with in your program, make sure following two points are checked:
1. Number of opening braces should be
equal to number of closing braces.
2. With in while, for, if,
else statements if there are more than one statement they should be
enclosed in Opening and Closing Braces. ({ ....
})