It is System.in, not System.in().
mvmalderen
Posting Maven
2,612 posts since Feb 2009
Reputation Points: 2,221
Solved Threads: 281
Skill Endorsements: 36
Or change line 8 to:
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Although i have made corrections in your code but even then it is running for infinite
Yes, that happens when a value > 2 is entered for n, the while loop will keep looping as long as n > 2, and since the value of n never changes during loop execution, that will in theory be forever.
mvmalderen
Posting Maven
2,612 posts since Feb 2009
Reputation Points: 2,221
Solved Threads: 281
Skill Endorsements: 36
its correct, it just doesn't make any sense. it 'll cause the loop never to be executed, but if that's what the OP was going for ...
(although I suspect he may have intended the second 0 to actually be his o variable)
stultuske
Industrious Poster
4,489 posts since Jan 2007
Reputation Points: 1,377
Solved Threads: 628
Skill Endorsements: 25