Java Tutorial

Java Tutorial

Java is an OOPs language that can be learnt and practiced easily. The laborious code of C/C++ involving lot of control structure iterations simple forget in Java.  Java comes with many predefined methods which make coding simple and fast. For this reason Java is known as "Production Language". To achieve this goal, Java came with special features like platform-independent, implicit memory management etc. Let us go further into the Java Tutorial.

Java does not support pointers. You can write a Linked List program with all the operations without using pointers. As memory is automatically managed either creation or destruction, Java does not support memory functions like malloc(), calloc(), sizeof(), free() delete() etc. Java is object-oriented with the support of Encapsulation, Inheritance and Polymorphism. The basic constructs of Java code comprise of classes, variables, methods and constructors etc. Java does not support destructors as garbage collector will be working at the background to destroy the memory that is not used by the remaining part of code.

Let us write a simple application and then go further into this Java Tutorial.

Java TutorialOutput screenshot of Demo.java on Java Tutorial
,

Observe, the whole code lies within the class declaration of opening brace and closing brace. For this reason, even the main() method is written within the class only. The whole code is known by the name called Demo. The package java.lang is imported. A package of Java is equivalent to a header file of C/C++. A package contains classes. java.lang package contains classes like String and System used in the program. As these two classes are very much needed for every Java class you write, this package is implicitly imported if the Developer does not import himself. Like this many things are automatically taken by Java and is one of the reasons why Java simple.

A public class can be accessed by any other class without any restriction. public is a keyword of Java and the other 4 keywords used in the code are import, class, static and void.

public static void main(String args[])

The main() in Java comes with a few properties. public means can be accessed without any restriction, static means can be called without the need of an object, void means does not return a value and finally String args[] parameter is used to access command line arguments.

System.out.println(“Hello World”);
System.out.println(“Best Wishes”);

println(“Hello World”) is a method which prints the parameter Hello World at command prompt. ln in println() adds a new line character equivalent writing \n in C-lang. That is, \n is inbuilt into the method itself.

To land correctly in Java and to sail smoothly follow the links in the same order.

1. Java Language – Introduction
2. Java for Beginners
3. Basic Java
4. What is a class in Java?
5. Classes of Java
6. Java Types of Classes

Once get acquainted with the basics, now you can go slowly into the other step-by-step.

Leave a Reply

Your email address will not be published. Required fields are marked *