Core Java Tutorials

This series of Core Java tutorials is designed for students and working professionals by providing basic to advance, in depth knowledge of all core concepts with the help of simple and easy to understand code examples.

Java is a widely used open source high-level programming language originally developed by Sun Microsystems and released in 1995.

Here you will learn the fundamentals of Core Java (OOPS, Class, Interface etc.) along with advanced topics like Collection API, File Handling, Exception Handling etc.

Example blog post alt

Install Java and Environment Setup on Windows, Linux or Mac OS

In previous article we saw What is Java? Where and Why to use Java? And features of Java programming language. In this particular article we will see how to setup Java environment in local machine.

Continue reading

Example blog post alt

Create a Java Project in Maven and import it in Eclipse IDE

In this particular blog we will discuss ?How to create a Java Project in Maven?, ?Import maven java project in eclipse ?. and ?create a jar from java maven project?.

Continue reading

Example blog post alt

Java Basic Syntax and Hello World Example

Java is a simple and easy to understand programming language, most of its syntax is inherited from c and c++. In Java, classes are the root of each program written, everything goes under a class.

Continue reading

Example blog post alt

Datatypes and Variables in Java Programming

In general programming terms a variable is a symbolic name that points to some reserved storage location. Every storage location that is pointed by a variable can consists of some value or it can be empty, that means a variable is an identifier for some value so that the operations can be performed on that value.

Continue reading

Example blog post alt

Operators in Java

In this article we will see 'What are available Operators in Java in Java', and how to use them with example.

Continue reading

Example blog post alt

Java Loops - for, while and do-while

In this article we will see looping in Java, loops are used to execute a block of code saveral times. There are three types of loops in Java, for loop, while loop and do-while loop. We will see their syntax and usage with example in rest part of this article.

Continue reading

Example blog post alt

Java Decision Making - if else and switch statements with example

If-else statements are most commonly used decision making keywords in any programming language and hence in Java. If-else statements works on the basis of a conditional expression in if(condition_expression), if the condition returns true than the code in if?s body executes and if the expression returns false than code in else?s body executes. Here is a basic syntax of simple if-else statement.

Continue reading

Example blog post alt

Java packages and Import statement with Example

In this article we will see what are 'Java packages and Import statement in Java', and how to use Java packages with example.

Continue reading

Example blog post alt

Type Casting in Java

In this article we will see 'Type Casting in Java', and how to use Type Casting with example.

Continue reading

Example blog post alt

Object Oriented Programming Paradigm - OOPS

Java is an object oriented programming language, a language is considered as a programming language if that language has following properties. 1) Abstraction 2)Inheritance 3) Polymorphism 4) Encapsulation

Continue reading

Example blog post alt

Object and Classes in Java with example

Java is a object oriented programming language, that means it solves problems by mapping them to real world objects.

An object-based Java application is a Java application whose design is based on declaring classes, creating objects from them, and designing interactions between these objects.

Continue reading

Example blog post alt

Methods and variables in Java with example

Method describe behaviour of an object. A method is declared to perform an operation and has statements (logic) to be performed on the instances of the class.

Continue reading

Example blog post alt

What is an Interface in Java - Marker and Nested Interfaces

An interface is a mechanism to obtain full abstraction in java, interfaces can contain constants, nested types and abstract methods with no body or implementation at all. Interfaces can not be instantiated on their own so must be implemented by a class or extended by some other interface to be used.

Continue reading

Example blog post alt

Constructors in Java with example

In Java a constructor is a special type of method, which is used to instantiate (create an object) the class.

A constructor must have the same name as the name of the class, it may be parameterised or without any parameter, constructors are solely used to instantiate a class and do not have return value.

Continue reading

Example blog post alt

"this" keyword in Java with example

In Java "this" keyword is used to refer the current object, and can be used to call current class constructor.

Continue reading

Example blog post alt

Inheritance in Java with Example

In this article we will see 'What is Inheritance in Java', How to used it, super class and sub classes with example.

Continue reading

Example blog post alt

Super keyword in Java - Example and Explanation

In this particular blog we will see What is super keyword in java. We will walk through all possible scenarios to use super keyword in java programming.

Continue reading

Example blog post alt

Method overriding in Java with example

In this article we will see 'What is method overriding in Java', and how to use it with example.

Continue reading

Example blog post alt

Method Overloading in Java - Example and Explanation

On this particular blog we will come across a very useful and frequently used concept i.e. Method Overloading. We will see the conditions and scenarios of, usage of method overloading in java and when it is overloading and when it is not.

Continue reading

Example blog post alt

Abstract classes in Java with Example

In this article we will see what are 'Abstract classes in Java', and how to use them with example.

Continue reading

Example blog post alt

Nested Inner Classes in Java

In this article we will see about 'Nested Inner Classes in Java', and how to use Nested Class with example.

Continue reading

Example blog post alt

How to create an Immutable class in Java - Example

An immutable class in Java is a class, whose object's states can not be changed once created like String, Integer, Float etc. In this article we will see what is an Immutable class, what are benefits of having an Immutable class and how to construct a perfect immutable class in Java.

Continue reading

Example blog post alt

Access Modifiers in Java with Examples

In Java there are three access modifiers public, private and protected but there is one more access level called default. If any class, method or variable does not have public, private or protected access level than the access level is called default. So in Java everything has a access level, at least default.

Continue reading

Example blog post alt

Encapsulation in Java - Example and Explanation

In this particular blog we will look into a very useful concept in java i.e. Encapsulation. Encapsulation is one of the four (Abstraction, Encapsulation, Inheritance & Polymorphism) OOPS concepts in Java.

Continue reading

Example blog post alt

Difference between Static and Dynamic binding in Java

In static binding, the method or variable version that is going to be called is resolved at compile time, while in dynamic binding the compiler could not resolve which version of a method or variable is going to bind.

Continue reading

Example blog post alt

Difference between Comparator and Comparable in java

In this particular blog we will see Difference between Comparator and Comparable in java and How to sort a collection or array of objects in Java.

Continue reading

Example blog post alt

Anonymous inner class in Java - Example and Explanation

In this particular blog we will look into a special case of Inner Classes i.e. Anonymous inner classes. In java anonymous classes are also called anonymous inner classes, the fact behind this statement is that Anonymous classes are always defined inside another class and there is no anonymous class without the word inner.

Continue reading

Example blog post alt

Java Inner Classes - Example and Explanation

Inner Class in java so called nested class is nothing but a class that is being defined inside another class. Inner classes are beneficial in two scenarios i.e. access control and naming control.

Continue reading

Example blog post alt

Sub Class and Super Class Relationship - Java Inheritance

In todays discussion we will come across the relationship in between a Sub Class and a Super Class in Java. In java classes can be derived from another classes, the class that is being derived is called a subclass and the class from which the subclass is being derived is called a superclass.

Continue reading

Example blog post alt

Arrays in Java - Declaration, Initialization and Iterating through an Array in Java

In this article we will learn about Array Declaration, Initialization and Iteration in Java. We will come to known ways of array declaration, assigning values to an array and iteration through an array to access values.

Continue reading

Example blog post alt

Enums in Java, Declaration and Implementation with Example

In this article we will see about Enums in Java, we will come to know what is Enum in Java?, How to declare a Enum and How to access Enum values. Enum were introduced in Java5.0 to restrict the value of a variable to some predefined options, this can reduce bugs in applications.

Continue reading

Example blog post alt

String Handling in Java - Difference between .equals() and '=='

In this particular blog we will dive into a very useful concept i.e. "String Handling in Java". In simple words a string can be defined as a sequence of characters, but in Java it a String .

Continue reading

Example blog post alt

Serialization and Deserialization in Java - Example

Java serialization is a mechanism to persist Java objects in a ordered or sequenced form of bytes, it includes objects data and object type and type of data that is stored in it as well.

Continue reading

Example blog post alt

Inheritance in Java Serialization - Example and Explanation

In our previous discussions we came across, Serialization, serialVersionUID and transient variable. In this particular blog we will see Inheritance in Serialization.

Continue reading

Example blog post alt

Exception Handling in Java

In this article we will see 'Exception Handling in Java', Throwable class, and Java Exception hierarchy.

Continue reading

Example blog post alt

Difference between Checked and Unchecked Exceptions

An Exception is an unwanted situation or event that occurs during the execution of a program, exceptions may lead to termination of the program if not handled properly.

Continue reading

Example blog post alt

Exception Handling using try, catch in Java

In this article we will see 'What is try and catch in Java', and how to use them with example.

Continue reading

Example blog post alt

'throw','throws' and 'finally' keyword in Java Exception handling

In this article we will see 'What is finally keyword in Java', and how to use finally with combination of try and catch with example.

Continue reading

Example blog post alt

User defined exceptions in Java with Example

In this article we will see what are 'User defined exceptions in Java', and how to define and use user defined exceptions with example.

Continue reading

Example blog post alt

What is Garbage Collector and How it works in Java with example

Like any other programming language, java programs too needs some memory to perform its operations. The memory is divided in a number of regions like Stack, Heap , Method Area .. etc.

All Java objects live and die in Heap Memory and this is the only part of memory where Garbage Collector performs its operations.

Continue reading

Example blog post alt

Java collection framework - Set, List and Map Interfaces in Java

Collection framework provides interfaces and class implementations that enable data handling easy and meaningful. Using collections one can store, retrieve and manipulate the data very effectively and easily.

Continue reading

Example blog post alt

ArrayList Implementation in Java - Java Collection Framework

We will come to know properties of ArrayList and Examples of how to use ArrayList in java to get more from it. ArrayList is a useful class implementation of Java Collection framework.

Continue reading

Example blog post alt

HashMap Implementation in Java - Java Collection Framework

We will come to know properties of Java Hash Map and Examples of how to use HashMap in java to get more from it. Java Hash Map is a useful class implementation of Java Collection framework.

Continue reading

Example blog post alt

HashSet Implementation in Java - Java Collection Framework

In todays discussion we will talk about HashSet in details, we will come to know properties of Set collection in Java using HashSet and Examples of how to use Hash Set in java to get more from it

Continue reading

Example blog post alt

How to override hashCode() and equals() methods in Java - Example

In this article we will see ?hashCode()? and ?equals()? methods from java.lang.Object class in details. We will see different implementations and how to override them in efficient manner.

Continue reading

Example blog post alt

How HashMap works in Java or Internal Working of HashMap

One of the most popular and frequently asked question from Core Java interview is, How HashMap works in Java or Internal Working of HashMap or How get() and put() methods of HashMap works or How HashMap ensures uniqueness of its keys.

Continue reading

Example blog post alt

Create, Rename & Delete a file in Java - Java File Handling

How to create a file in Java, How to rename a file in Java & How to delete a file in Java. We will use java.io.File class to perform the create, rename and delete operations.

Continue reading

Example blog post alt

Read and Write a file in Java using Buffered Streams - Java IO (Buffered Streams)

In this particular blog we will dive into ?Buffered Streams. We will come to know how to read from and write to a file in java using Bufferd Streams and why this is a good practice to use buffered streams over byte and character streams.

Continue reading

Example blog post alt

Read and Write a file in Java using Byte Streams - Java IO (Byte Streams)

In our previous discussion we came across, the foundation of Java I/O and a little deep about InputStreams and OutputStreams. In this particular blog we will see Byte Stream and how to Read and Write a file in Java using Byte Streams

Continue reading

Example blog post alt

Read and Parse a CSV file in Java - Convert data from CSV to Java object

In this particular blog we will see How to read a csv file in Java and How to convert data from a csv file to java object. A csv file is a simple text file containing text data, separated with a white space or a comma.

Continue reading

Example blog post alt

Jdom 2 Xml Parser - Read xml and Create xml in Java

Jdom is the most developer friendly XML parser to read and create an xml file in Java. Jdoms programming friendly nature provides mechanism and implementation that makes it easy to xml parsing for java developers.

Continue reading

Example blog post alt

Json in Java - Convert Json object to Java and Java object to Json

In this tutorial we will see step by step explanation and implementation of parse JSON in Java using Gson. GSON provides two useful methods and everything moven around these two methods.

Continue reading

Example blog post alt

SAX parser for Xml - How to read xml file in Java using SAX parser

SAX parser is the most commonly used xml parser in Java after DOM, unlike DOM Sax does not loads the XML into memory before parsing it, nor it creates any type of object from XML.

Continue reading

Example blog post alt

DOM xml parser - Read and Create xml file in Java using DOM

In previous discussion we came across different parser for xml in Java and a brief introduction of them. In todays discussion we will see how to parse an xml in java using dom xml parser.

Continue reading

Example blog post alt

Java - Xml parser - DOM, SAX, JDOM, XPATH and JAXB parsers in Xml

In today discussion we will talk about Different type of Java XML parser and their implementations. Java provides full support with a number of general purpose xml readers to read, write and manipulate xml data and documents.

Continue reading

Example blog post alt

JDBC in Java - Create JDBC connection in Java

In this particular blog we will come across How to create a JDBC connection in Java and What are Class.foreName() and DriverManager classes in JDBC.

Continue reading

Example blog post alt

JDBC in Java - Create table in JDBC Hello World Example

In this particular blog we will see How to create a table in jdbc and a brief overview of Jdbc Statement and difference between them.

Continue reading

Example blog post alt

JDBC in Java - Insert values in a table in JDBC Hello World Example

Welcome to third part of JDBC in Java tutorial Series, In previous discussions we came across, How to create a connection in JDBC and Create table in Java JDBC.

Continue reading

Example blog post alt

JDBC in Java - Delete a row in JDBC Hello World Example

In this particular blog we will come across How to delete a row from a table in JDBC. We will create a connection to db and that obtain a statement to execute query on it.

Continue reading

Example blog post alt

Create connection with FTP server in Java - Using Commons Net API

In todays discussion we will came across How to establish connection with FTP server in Java. We are using apache commons-net API that holds all necessary classes to deal with FTP operations.

Continue reading

Example blog post alt

Get list of files from FTP Server in Java - Using Commons Net API

In todays discussion we will came across How to get list of files from FTP server in Java. We are using apache commons-net API that holds all necessary classes to deal with FTP operations.

Continue reading

Example blog post alt

Upload files to FTP Server in Java - Using Commons Net API

In todays discussion we will came across How to upload files to FTP server in Java. We are using apache commons-net API that holds all necessary classes to deal with FTP operations.

Continue reading

Example blog post alt

Download files from FTP Server in Java - Using Commons Net API

In todays discussion we will came across Download files from FTP Server in Java. We are using apache commons-net API that holds all necessary classes to deal with FTP operations.

Continue reading

Example blog post alt

Delete files from FTP Server in Java - Using Commons Net API

In todays discussion we will came across Delete files from FTP Server in Java. We are using apache commons-net API that holds all necessary classes to deal with FTP operations.

Continue reading

Example blog post alt

Create and Delete a directory on FTP Server in Java - Using Commons Net API

In todays discussion we will came across Create and Delete a directory on FTP Server in Java. We are using apache commons-net API that holds all necessary classes to deal with FTP operations.

Continue reading

Example blog post alt

Interfaces in java, declaration and Implementation with Examples

Interfaces are kind of a contract in Java Programming, what contract means here is you can have a number of method declared in an interface and every class that is implementing this interface must implement all methods of the interface, for example you can have a interface Car like:

Continue reading

Example blog post alt

"super" keyword in Java with example

In Java, super keyword is used to refer to immediate parent class of a child class. In other words super keyword is used by a subclass whenever it need to refer to its immediate super class.

Continue reading

Example blog post alt

Method overloading in Java with example

In this article we will see 'What is method overloading in Java', and how to use it with example.

Continue reading

Example blog post alt

String Handling in Java with Example

In this article we will see what are 'Java Strings', and how to define and use Strings in Java with example.

Continue reading

Example blog post alt

Java Programming - Introduction

Java is a most commonly used and widely accepted object oriented programming language of today. When it comes to choosing an programming language for companies and individuals to develop a simple or complicated enterprise web application.

Continue reading

Example blog post alt

How to make a class Immutable in Java - Example & Explanation

What is immutable class in Java? And How to make a class immutable in java? Are two very popular and hot topics as if today. In this particular blog we will look into these two in details and will try to understand benefits if immutable classes in context of Java Language.

Continue reading

Example blog post alt

How to override equals() in Java - Example

In our previous discussions we came across a quick introduction to Java?s Collection API and Implementation classes for List, Set and Map interface. In this particular blog we will discuss about a very useful topic i.e. "Why to override equals() in Java" and "How to override equals in Java".

Continue reading

Example blog post alt

Java - Introduction and Overview of Language

Java is a High Level computer programming language that was initially invented by James Gosling. In June 1991 James introduces Java with an initial name oak.

Continue reading

Example blog post alt

throw, throws and finally keyword in Java Examples - Exception Handling in Java - Part 3/3

Then we came across how to use try-catch in java and their examples. In this particular blog we will discuss throws, throw and finally keywords and their examples in Java.

Continue reading

Example blog post alt

try catch in java Examples - Exception Handling in Java - Part 2/3

In our previous discussion we cam across the Basics of Exception Handling in java, we came to know what an Exeption is exactly ?, how java atmosphere handles Exceptions and we understands difference between Checked and Unchecked Exceptions.

Continue reading

Example blog post alt

This keyword in Java - Example of This keyword in Java

In this particular blog we will see working and functioning of a very basic and commonly used keyword, i.e. this keyword in Java.

Continue reading

Got a technical query, or stuck somewhere ?