Srini Jayaraman wrote: . . . runs fine for me without any issues in IDE but getting an error on line 27 when i compile this using command prompt by saving this code in a notepad file. . . .
What sort of new errors are you getting? If the code gets to the javac tool at all, you must get the same errors from the IDE as from the command line; if there are any differences, javac must be receiving different code.
But there is no such thing as a notepad file; there are only text files. It is possible that notepad is doing something to your encoding, or other things about the format of the file, which are causing your problems. Stop using notepad; it isn't good for programming. Try NotePad2 or NotePad++ instead (I prefer NotePad++ myself, though the two are similar).