How to write faster Java programs?

I tried to understand the methods used by some top programmers on codechef like “Egork”…but couldn’t understand that…

Hi!..first of all you should go through this. Secondly, the method used by top programmers like Egork, rudradevbasak etc. are the ones optimized for I/O performance and modified for the input format that generally appears in problems of codechef. If you have decent knowledge of JAVA, you should be able to understand them. However, if you are new to Java then look them up on the internet: it shall be great learning opportunity. Also, in your solution of CONFLIP, I see that you have used import*; Try to import only those classes which you need. Finally, go through the solutions of more users who use Java rather than going through solutions of only one user.