How many bytes does the java short type occupy?
The short type occupies 2 bytes, 16 bits.
Byte: byte, a unit of measurement used to measure storage capacity, bit (bit).
One byte is equal to 8 bits 1byte = 8bit.
java short type
The short data type is a 16-bit, signed integer expressed in two's complement number
The minimum value is -32768 ( -2^15);
The maximum value is 32767 (2^15 - 1);
Short data type can also save space like byte. A short variable is half the space occupied by an int type variable;
The default value is 0;
Example: short s = 1000, short r = -20000.
Short will be promoted to int type or higher type during operation. This is because Java will automatically treat short data as a literal of type int during the operation. The same is true when performing operations on the byte type, which will be automatically upgraded by Java.
Java integer types
Each integer type in Java has a fixed table number range and field length, which are not affected by the operating system. Ensure the portability of Java programs.
The integer constant in Java language defaults to type int. When declaring long type, you need to add l or L after it, otherwise an error will occur
Type | Occupied storage space | Number of tables Size |
---|---|---|
byte | 1 word Section | -128-127 |
short | 2 Bytes | -215~2 15-1 |
int | 4 bytes | -231~231-1 |
long | 8 bytes | -263~263 -1 |
Recommended learning: Java video tutorial
The above is the detailed content of How many bytes does the java short type occupy?. For more information, please follow other related articles on the PHP Chinese website!

Start Spring using IntelliJIDEAUltimate version...

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

Java...

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

How to set the SpringBoot project default run configuration list in Idea using IntelliJ...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools