Skip to main content

Overview of Java


Check full java topics on this main page

What is a programming language?

Program - In simple terms, It is the language used by humans to interact with hardware(Computer). For more information on programming language, check this post programming language

Key components in Java programming

There are 3 key components in java

1. Java Development Kit(JDK)

2. Java Runtime Environment(JRE)

3. Java Virtual Machine(JVM)

These are discussed in detail in this article Java architecture

Key features of Java

Some key features are mentioned below

  • Platform independent:- In Java after the source code gets compiled, it will get converted to byte code(.class file). In other languages, it will get compiled to platform-specific code.

  • Object-Oriented:- As this is object-oriented, We can reuse the code rather than creating a new one, and code maintenance is easy. There are a lot of OOPS concepts we are going to cover in other posts

  • Multithread:- Java can execute multiple tasks simultaneously.

  • Better Performance:- As Java is using (JIT compiler - Just-In-Time) java code can run more efficiently. If the class is already compiled in the JIT compiler, it will not execute for the next time. So, Its performance is better than others.

Let us cover all the feature in Java in upcoming articles

Java editions

There are four Java editions, 

  1. Standard Edition(Java SE)
  2. Enterprise Edition(Java EE)
  3. Micro Edition(Java ME)
  4. Java FX
Syntax
class <class name>
{
     public static void main(String[] args) //Please have a look at below ref for different declaration

    {

        // Instruction for the program(What needs to done)

    }

}

Sample program

Program Definition

The program will execute from top to bottom starting from the main method. 

  • class: Instructs code to create a new class in this step
  • class name: Class name should be a noun and it should start with a capital letter
  • public static void main(String []args): This is the starting point of the program
    • Public: If you are using java edition other than JavaFX, the main method should be public. When you try to execute without public type JVM will not able to find the main method
    • static: This is the starting point of the program. This method should be called by the compiler before creating an object. As this main method is static, this can be called by the compiler before creating an object. 
    • void: For the main method JVM will not return any value. So, We are using void in the main method. 
    • main: Name configured in JVM, So we are using the main word
    • String[] args: We can give the argument from the command prompt
Alternatives declaration of the main method
  1. Order of modifier is not important - static public void main(String[] args)
  2. String[] args can be changed - main(String[] args),main(String []args),main(String args[])
  3. We can change array name in the main method - main(String[] x)
  4. We can mention array using var arg - (String... args)
  5. Can use a final modifier(We will cover this keyword in future)) - final public static void main(String[] args)
  6. Can use a synchronized modifier(We will cover this keyword in future)) - synchronized public static void main(String[] args)
  7. Can use strictfp modifier(We will cover this keyword in future)) - strictfp public static void main(String[] args)
  8. Can use many modifiers in the main method - final static synchronized strictfp public void main(String[] args)
Note: If we change any value in the main method we will not getting any error in compile time. But in runtime JVM will throw run time exception(NoSuchMethodError:main)
  • System.out.println: The System is a class present under java.lang. Under this class, there is a static variable of type PrintStream called out. println is a method present in PrintStream class.
We will see the above points in detail in upcoming topics.

Note: We will go through the full course and summarize it's advantages and disadvantages


Next Java Identifiers

Comments