How can I improve my java programming skills?

Can anyone to help me to improve Java programming skill? sometime I try to solve problems with Java but always get TLE, but when change my code to C/C++ get AC. I read FAQ and look some users codes. In the FAQ wrote that don’t use Scanner because it is very slow and suggest to use others. even I used them again sometimes I got TLE. In previous contest there are a lot of problems which no one solve with Java. for example “The Rise and Fall of Power”. this the first contest problem in the codechef but until now none solve this problem with Java.Any suggestion? or I don’t use Java during contest? :slight_smile:

If you are 100% comfortable with C or C++, use either one of those. For competitive programming, both are far better performance-wise than Java. The only advantage I see Java having over C++ and C is that it has well-documented API, which shouldn’t be a disadvantage for C++ programmers who are comfortable with the language.

Normally, I’d say that the language does not matter, and this is true to an extent. However, seeing as though you have switched and got AC in C++, it seems as though you usually come up with the algorithms that are borderline correct for C++, but not at all correct for Java. It is possible to get AC on Java for virtually any problem, but it might take some extra work.

So I’d recommend switching to C++.

1 Like

Well either of the languages has their advantages. As far as Java is concerned, it has classes for a lot of basic constructs and data structures. It depends greatly on the problem type. There are problems which can rely heavily on string processing but doesn’t require sophisticated data structures. Java is quite good for such problems. Start coding simple problems in both Java & C++ & observe the differences in time limits. If you want to use only java, this can help you a lot, as you will understand which constructs are taking more time(like Scanner). People solve certain problems in Pascal, Python etc. and their solutions come first in terms of time limit. So experiment problems with either languages and understand what they are good at -:slight_smile:

2 Likes

C++ has better performance, but don’t forget Java has double time limit in Codechef.

Well, Java is concerned, it has classes pro a bundle of basic constructs and data structures. It depends greatly on the crisis type. There are problems which can rely seriously on cord meting out but doesn’t require sophisticated data structures. Java is quite pleasant pro such problems. Start coding down-to-earth problems in both Java & C++ & observe the differences in spell limits. If you be looking for to spend just java, this can help you a bundle, as you will understand which constructs are taking more time(like Scanner). People solve several problems in Pascal, Python and the like. And their solutions get here paramount in conditions of spell limit. So experimentation problems with either languages and understand pardon? They are pleasant

thanks for your answer.

yes I know but even double time is not enough. I give one example which the first contest problem until now none solve with java.