sorry for being a troll...
its working in the online compiler fine now..
okay now i have a cool head ill explain what happened..
there is an online compiler for
java :
www.ideone.com
you guys should check it out..
I was having trouble comipling and running this code as I was expecting to give inputs in the normal way..during run time like it happens when you use a normal compiler(offline)..but what i missed was that in online compilers, you have to give inputs before you run the program. i figured it out now and got it.