I
I
Ilya Podolsky2021-03-06 11:01:43
Java
Ilya Podolsky, 2021-03-06 11:01:43

Why are byte and short data types needed in Java?

Why are there so many data types in a programming language?
Especially byte or short, because they are completely replaced by int. What are they needed for? What is their profit?

ps I study programming from scratch

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Orkhan, 2021-03-06
@lamerizhottabicha

Good afternoon!

Why are there so many data types in a programming language?
Especially byte or short, because they are completely replaced by int. What are they needed for? What is their profit?

The data type int takes 4 bytes, while byte takes 1 byte and short takes 2 bytes.
Accordingly, in conditions of limited memory, only the appropriate types of primitives should be used.
60436b2020216873254157.png

V
Vladimir Korotenko, 2021-03-06
@firedragon

Mainly size in memory. Well, on the network, data is transmitted precisely by bytes, so that they would not be repackaged and not given once again and they are used.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question