Cover image for Master Java: Basics. 🚀

Master Java: Basics. 🚀

rakshakannu profile image Raksha Kannusami ・2 min read

This is going to be the first article of the Master Java series. 🎉

🔰 History of Java:

Java was created in 1995 by James Gosling(who is also called as the father of Java). James and team (who were working for Sun Microsystems owned by Oracle) started with a project to create a language for television technology but apparently, at that time Java was too advance for television and it turned out to be more useful for programming.

Naming this language also has an interesting back story. First, they named it Green talk (which had a file extension .gt). Then they changed it to Oak (Interestingly, Oak is the national tree of USA) then they finally changed it to Java (since the name Oak was already trademarked by Oak technologies).

Fun fact - Java is an island in Indonesia where the first coffee was made called Java coffee and apparently James made this decision of naming it Java while having coffee in his office.

🔰 Why Java over other languages?

Java has amazing advantages compared to other languages and that is the reason it has gotten so much name in the software industry for the past two decades. Some of the advantages of Java are as follows:

🎯 Object-oriented language - you can create programs in modules, which means you can reuse these programs.
🎯 Platform Independence - Create your program in one type of machine and run it on any other machine using the help of JVM(Java Virtual Machine).
🎯 Secure - Java has a security manager that defines the access of classes.
🎯 Multithreading - can perform multiple tasks at the same time.
🎯 Memory - Java uses heap and stack for memory allocation, which helps us to store and retrieve data easily.

🔰 Writing your first java program:

Let us write a simple java program.

class first{
    public static void main(String args[]){
    System.out.print("Hello world");

save these lines of code in a file called first.java (name should match with our class) and run the following commands in the command line.

javac first.java
java first

We should get the output as Hello World! Let us understand the parameters that we used.

class keyword is used to declare a class in java.
public keyword is an access modifier that represents visibility. It means it is visible to all.
static is a keyword. If we declare any method as static, it is known as the static method. The core advantage of the static method is that there is no need to create an object to invoke the static method. The main method is executed by the JVM, so it doesn't require to create an object to invoke the main method. So it saves memory.
void is the return type of the method. It means it doesn't return any value.
main represents the starting point of the program.
String[] args is used for the command-line argument. We will learn it later.
System.out.println() is used to print statement. Here, System is a class, out is the object of PrintStream class, println() is the method of PrintStream class.

... To be continued! 🎉

Keep learning! keep coding! 💖

Posted on by:

rakshakannu profile

Raksha Kannusami


There is magic in code! 🌟 Constantly learning and sharing to get better at coding. 🎯


markdown guide

I know it's early to ask but can you tell me how to create a user defined 'FastReader class'.
I want to use it because Scanner class takes a lot of time resulting in time limit exceed in competitive programming and BufferReader class is also never recommended in competitive programming because of its complexity.


Hey Parth! When it comes to competitive programming, if you are ending up with TLE, try to optimize the time complexity by changing the approach of solving the problem, but if you are not able to do that, then you can use the FastReader class, I will be writing the article on it soon. Meanwhile do refer to the article given by Mohamed given in the comments!

PS - it is always better to use Scanner class since fast I/O methods make your program very lengthy. And these type of questions are really rare and won't be asked in interviews as such!


While the author replies, check out the geeks-for-geeks post about this: geeksforgeeks.org/fast-io-in-java-...


Great post! Looking forward to the next one.