All posts in "Java"

How to compare enums in Java

September 6, 2016

Summary The best way to compare enums in Java is == operator, like in an example below:

Comparison of == and equals methods There are two ways to compare enums in java: == operator and equals() method. First of all, I would like to show you an implementation of method equals() of java.lang.Enum:

As […]


Dependency injection in Java

August 3, 2016

In this tutorial lesson, we will discuss one of the major concepts of Spring which is dependency injection. Before I explain to you what dependency injection is, let’s have a look on below example. 1. Tightly coupled classes example Let’s create the class named SlowEngine with the method start. For the sake of this example, […]


Java methods

July 29, 2016

In Java there is a type of entity called a method. Methods help us in organizing our code. A method consists of a header and a body. Let’s have a look at the example of a method:

1. Method header 1.1. Method modifiers The first line of a method is a header. It contains important information […]


Java variables

July 9, 2016

In this lesson of Java tutorial, we are going to talk about Java variables. Variables are used to store some values. Maybe you remember from your math lessons at school that you used some variables, e.g. x. You assigned some value to it, like:

and you did some operations on these variables. Variables in […]


Java – Convert String to int – Detailed guide

May 14, 2016

In most of the cases, the best option to convert String to int in Java is to use the method Integer.parseInt(String):

Let me explain this method below. Integer.parseInt(String s) method: The Integer.parseInt(String) method takes a String as a parameter and returns a primitive int value.

If you run the code above, you will […]

Page 4 of 4