Home » Author Archives: Ilias Tsagklis (page 51)

Author Archives: Ilias Tsagklis

Ilias Tsagklis
Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.

char

This is an example of how to use a char type in Java. The char data type is a single 16-bit Unicode character. It has a minimum value of ‘\u0000’ (or 0) and a maximum value of ‘\uffff’ (or 65,535 inclusive). In order to create variable of char type you should type the char keyword in a variable. Let’s take ...

Read More »

boolean

With this example we are going to demonstrate how to use a boolean type in Java. The boolean data type has only two possible values: true and false. Use this data type for simple flags that track true/false conditions. This data type represents one bit of information, but its “size” isn’t something that’s precisely defined. In short, to create variable ...

Read More »

Each Enum Instance a different sub-class

In this example we shall show you how to have each enum instance represent a different sub-class. To make each enum instance represent a different sub-class one should perform the following steps: Create an enum with different enum constants. Give each enum constant a different behavior for some method. Declare the method abstract in the enum type and override it with ...

Read More »

Enum for Singleton and Utility class

enum Singleton { INSTANCE; } enum Utility { ; // no instances } Related Article: Java Secret: Using an enum to build a State machine Reference: Java Secret: Using an enum to build a State machine from our JCG partner Peter Lawrey at the Vanilla Java blog

Read More »

Arithmetic Operators

With this example we are going to demonstrate how to use the arithmetic operators in Java. The arithmetic operators supported by the Java programming language are the Additive operator (also used for String concatenation), the Subtraction operator, the Multiplication operator, the Division operator, and the Remainder operator. In short, to use the arithmetic operators you should: Use the Additive operator ...

Read More »