How to convert the C, C++ code to java?
You must know what methods translate to same actions in Java. For example print in C++ will be System.out.println/print(""); in java.
Learn Java so that you know the language. Once you learn the language, it'll be easy for you to translate the same concepts over to it; maybe even better.