Music recommendation for this article: https://www.youtube.com/watch?v=mPymRFeTJa4

Pre-requisites: Previous knowledge of any language.

In this series, I will document myself learning Java, and I think this is a pretty efficient way of helping you learn Java as well. I will not waste time on Hello World and installation and all, instead, I will solve Interview Kit questions from Hackerrank in Java. First, let’s go over the ‘why to learn Java’ thing (these are personal):

  1. Job
  2. I have an exam for Java 101 (I did not choose this fate)

That’s…about it.

Let’s go over Java’s architecture.

Java is built on the idea of Write Once, Run Everywhere- Let me explain that. Java doesn’t run right away. It converts your code from .java (hint: Extension for Java files) to .class (Your Java compiled codes, also called Bytecodes).

From here there is a JVM or Java Virtual Machine which takes your .class files and interprets it line-by-line upon run request. This almost makes Java virtually platform-proof. You might have heard the terms JRE and JDK thrown around. Long story short: JRE is Java Runtime Environment- containing JVM+Essential libraries and JDK is Java Development Kit, which is JRE+Development tools. Before I go any further, let me go over once again on how JVM is structured. If you know C or C++ compilation process: Once you type ‘gcc <filename>.c’ (Or any other compilation method, basically once you compile), it gives you your .obj files, which then go via a linker upon runtime and then you get your .exe. All of this happens in one go in C.

In Java, once you press run, it first undergoes build process, where your code is checked for errors, your dependencies analyzed and your code is converted to bytecode. You get .class, but unlike C, these are not clubbed or linked, they are as is. Upon runtime, the bytecode goes through JVM, which is a virtual machine residing inside your RAM, and the .class objects are run via JIT (Or Just in Time compiler, since it literally compiles Just in Time). So you don’t get binaries the same way as C unless you specifically export. That’s all about Java for now. Next tutorial will be a very simple problem from Hackerrank’s Interview Preparation Kit. You could also go through Hackerrank’s Java practice track to get up to date if you feel underconfident (without a reason, that is, because I will also be doing Java for the first time with these problems).

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store