Friday, 31 October 2014

Regular expression

This article talks about the classes and quantifiers allowing to execute design pattern on a String.

Wednesday, 29 October 2014

Primitives

The ranges of primitive types


A primitive is stored as one or many bytes (1 byte = 8 bits). As all primitives are signed, the leftmost bit is used to represent the sign 0 for positive and 1 for negative. The rest of the bits represent the value.

Monday, 27 October 2014

Overriding and Overloading


You can not override a static method or an instance variable (their value is always defined from the reference type).

Sunday, 26 October 2014

Object Casting

There are 2 types of reference variable casting: upcasting and downcasting.

Wednesday, 22 October 2014

NumberFormat

The abstract class "NumberFormat" allows formatting a number using a "Locale" object.

Tuesday, 21 October 2014

Modifiers

There are two kind of modifiers:
  • access modifiers: public, protected and private and default 
  • non-access modifiers: final, abstract, strictfp, ... 

Monday, 20 October 2014

Interface

An interface defines a contract which has to be implemented by a class. The implementation of an interface should strictly follow the contract: polymorphism is not allowed. 

Saturday, 18 October 2014

Inner and nested classes


There are 4 types of inner classes:
  • an inner class (as an instance member of an outer class),
  • a method-local inner class,
  • an anonymous inner class,
  • a static nested class.

Thursday, 16 October 2014

Generics

'Generics' let you enforce type safety on Collection, classes and methods.

Tuesday, 14 October 2014

File I/O

Let's review the classes allowing to manage the input/output operations on a file:
  • File
  • FileReader and FileWriter
  • BufferedReader and BufferedWriter
  • PrintWriter

Sunday, 12 October 2014

Exception and Error

When a code throws an Exception, its intention is to notify the other codes depending on it that an unexpected error happened.

In the other hand, an Error is thrown by the Java system to notify about a non-recoverable error. Therefore, when an exception can be thrown and caught by your code, it is not a good practice to throw or catch an Error.

Thursday, 9 October 2014

HashMap structure

This small article talks about the implementation details of an HashMap.

Wednesday, 8 October 2014

The methods equals and hashCode

This article explains how the object equality and their hashcode work in Java and the rules to follow when overriding the methods 'equals()' and 'hashCode()'.

Tuesday, 7 October 2014

Monday, 6 October 2014

Compile and run a java program

This article details the commands to use to compile and run a java programs.

Constructor and initialisation blocks

This article talks about the rules to follow when implementing Java constructors and in which order the initialisation blocks and constructors are initialised at runtime.

Saturday, 4 October 2014

Console

The class java.io.Console can be used to write Java programs which can interact with users via command line.

Friday, 3 October 2014

Clone

Java provides a mechanism for creating copies of objects called cloning. There are two ways to make a copy of an object called shallow copy and deep copy.

Thursday, 2 October 2014

Assertion

The keyword "assert" has been added since Java version 1.4 and allows testing assumptions during development.

Wednesday, 1 October 2014

Arrays in Java

An array is an object and consequently it is stored in the heap. It is possible to create one or many dimensional arrays. Let's see the various ways to write arrays in Java.