Core Java (All)

Main Method in Java

The main method is the entry point to a desktop based core Java application.

Previously, we created our first Java program "" as:

public class Hello {

  public static void main(String[] args)





We then compiled it using javac as:


We then executed it as:

java Hello

And output was:


String Interning and Performance Tuning in Java

String interning is a method of storing only one copy of each distinct string value. Strings in Java are immutable and hence this sharing is perfectly safe and give you better performance. The distinct values are stored in a fixed-size hashtable usually referred to as string intern pool or string pool. The single copy of each string is called its 'intern'. You can read more about the basics of String interning with examples @ string-interning-in-java-with-examples.

Introduction to Deadlocks in Java

Deadlock involves a mutual interdependence between two or more threads. 

List of Stream Class Constructors for Quick Reference

This is a quick reference of constructors for various Stream classes.

You can quickly find out what all type of resources or streams a Stream class can be attached with. For instance, a BufferedReader do not have a constructor that can accept an InputStream, however an InputStreamReader has such a constructor that can accept an InputStream. So to use an InputStream such as, we can attach it to an InputStreamReader and then attach the InputStreamReader to a BufferedReader as:

[Example-Lab] Hands On Exercise and Quiz on Exceptions

Let us do a simple hands on excercise followed by some questions to understand exceptions better. For theory and concetps of exceptions in Java. you can refer to the note introduction-to-exceptions-in-java



Create a class MyClass and create three methods myMethod1(), Method2() and Method3().


Invoke Method2() from Method1() and Method3() from Method2().

Introduction to Strings in Java

A String is a sequence of characters (e.g. "Hello World").

A String is an object in java, and not a primitive. 


Creating Strings

We can create a String object in two ways:

  1. Assigning a String literal to a String variable

    • e.g. String greeting = "Hello world!";

    • Here, "Hello world!" is a string literal.

My First JDBC Program


1. Downloading, installing and configuring the database

See the installation and configuration note for your database.

2. Create table and insert data as:

Create table employee(empName varchar(20), id int PRIMARY KEY)

insert into employee values (‘name1’,1)

insert into employee values (‘name2’,2)

Path vs Classpath

The PATH environment variable contains a set of directories within the file system that the operating system uses to find executable files. When you type a command in command prompt, operating system will look for the corresponding executable in the current folder and then it will look inside every folder mentioned in the PATH environment variable in order. For instance, when you type javac, OS will search for java.exe within the current folder and then every folder mentioned inside in the PATH environment variable in order.

Access Modifiers in Java

Access modifiers are used to specify the accessibility or access levels of a type (class, interface) and its members (methods, variables and even constructors). There are three access modifiers and four access levels in Java. The three access modifiers are are private, protected and public. Four access levels (from most restricted to least restricted) are private, default (no modifier), protected and public. 

Constructors in Java

Constructors are used to initialize the state of an object when it is created. Constructors are invoked while creating objects, usually after the new keyword. A child class may also invoke a super constructor using the super keyword to initialize the parent object.

Constructors are similar in syntax to methods, but without any return type and have the same name as that of the class (case sensitive).





Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within!!!