10 common mistakes people make in Java — Part 2

This is the second article about common mistakes in Java. Let’s see the next 5 mistakes people make in Java. The first 5 are in the article below.

Andrei Albu
SCIENTIFIC ZOOM

--

Photo by Elisa Ventur on Unsplash

Below the first 5 common mistakes people make in java.

Let’s see the next 5!

6 — Confusing variable assignments with variable definitions

I will be brief.

int a = 3;

is different from:

a = 3;

The first line is a definition of a new variable called ‘a’ with the value ‘3’ stored in memory. The second line is a new variable assignment to the already existing variable called ‘a’. If you write:

int a = 3;

again, in the second line, the compiler with stop you with an error message.

Pay attention to the meaning of variable declaration, definition and assignment. They are three…

--

--

Andrei Albu
SCIENTIFIC ZOOM

Writer and Reader — I am 24. Writing about software, computers, programming languages, business, marketing, psychology and many other topics. Writing daily.