Home » Java Basics (page 5)

Java Basics

Java Comparable example

In this tutorial we will discuss about comparable objects in the Java programming language. Java provides the Comparable interface, which contains only one method, called compareTo. This method compares two objects, in order to impose an order between them. Specifically, it returns a negative integer, zero, or a positive integer to indicate that the input object is less than, equal ...

Read More »

Java Scanner example

In this tutorial we will discuss about scanners in Java. A Scanner in Java is a simple text scanner which can parse primitive types and strings using regular expressions. A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace. The resulting tokens may then be converted into values of different types. The Scanner class ...

Read More »

Java Inheritance example

In this tutorial we will discuss about the inheritance in Java. The most fundamental element of Java is the class. A class represents an entity and also, defines and implements its functionality. In Java, classes can be derived from other classes, in order to create more complex relationships. A class that is derived from another class is called subclass and ...

Read More »

Java Enumeration Example

In this tutorial we will discuss about Java Enumeration. The Java programming language contains the enum keyword, which represents a special data type that enables for a variable to belong to a set of predefined constants. The variable must be equal to one of the values that have been predefined for it. The values defined inside an enum are constants ...

Read More »

Java Dictionary example

In this tutorial we will discuss about dictionaries in Java. A Dictionary is an abstract class that maps keys to values. Every key is associated with a unique value and key are unique. Any non-null object can be used for either a key or a value. An attempt to insert either a null key or a null value to a ...

Read More »

Java Calendar example

In this tutorial we will discuss about Java’s java.util.Calendar and how to use it. The Calendar is an abstract class that provides methods for converting between time and calendar fields. Also, the class provides fields and methods for implementing a concrete calendar system. The Calendar field values can be set by calling the following methods: set, add and roll. In ...

Read More »

Java Map Example

In this post, we feature a comprehensive Java Map Example. We will discuss about Maps in Java. A Map is an interface that maps keys to values. The keys are unique and thus, no duplicate keys are allowed. A map can provide three views, which allow the contents of the map to be viewed as a set of keys, collection ...

Read More »

Java programming tutorial – Getting started with Java

In this tutorial we will discuss about the Java programming language and how to develop and execute our first application. Java is an object oriented programming language that aims for portability, high performance, robustness and security. The Java Compiler is used to transform the Java source files to bytecode, which can be executed by the Java Runtime Environment (JRE). Moreover, ...

Read More »

Encapsulation in Java

In this tutorial we will discuss about Encapsulation in Java. Encapsulation is the mechanism for restricting access to an object’s components. It aims for high maintenance and handling of the application’s code. Also, the encapsulation mechanism protects the members of a class from external access, in order to be protected against unauthorized access. Encapsulation can be described as a protective ...

Read More »

Java heap space – Everything you need to know

In this tutorial we will discuss about Java’s heap space. To begin with, the Java Virtual Machine (JVM) is the execution component of the Java Runtime Environment (JRE) that executes the bytecode residing in a Java .class file. While executing an application, new objects are created. The heap space is where all new objects are stored, while the application is ...

Read More »