Skip to main content

Primitive Data Types in Java

Java supports 8 built-in data types.


boolean - This data type is 1 bit in size and is used to represent a binary
condition, true or false.


byte - This data type is an 8-bit signed 2’s complement integer.
It can hold values ranging from -128 to 127.


short - This data type is a 16-bit signed 2’s complement integer.
It can hold values ranging from -32,768 to 32,767.


char - This data type is a 16-bit unsigned integer used to represent unicode characters.
It can hold values ranging from 0 to 65,535.


int - This data type is a 32-bit signed 2’s complement integer.
It can hold values ranging from -2,147,483,648 to 2,147,483,647.


long - This data type is a 64-bit signed 2’s complement integer.
It can hold values raging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.


float - This data type is a 32-bit signed floating-point number.
The range of values it can hold is +/–3.40282347^38.


double - This data type is a 64-bit signed floating-point number.
The range of values it can hold is +/–1.79769313486231570^308.


The syntax for declaring and initializing a primitive is:



<modifier> <type> <variableName> = <initialvalue>

Comments

Popular posts from this blog

Architecture Complexity

Here are the items to consider: Coding to an interface Service Oriented Architecture Automated Testing Domain Driven Design Custom Data Access Layer Layered architecture Complexity is relatively equal the number of lines of code. Note that complexity is not bad. It must be justified.

Repair Windows 7 System Files

8 out of 10 average PC users have their box’s system files altered by malwares, viruses, etc. We usually reinstall the OS if the antivirus and anti malware software did not perform their job well. Here’s one way to fix the corrupted system files without the need of restarting your Windows 7 box. 1. Run the Command Prompt as Administrator 2. Type the following command C:\Windows\system32\> sfc /scannow 3. After the verification phase, you will receive a message about your system files’ integrity Windows Resource Protection did not find any integrity violations.

Android Studio:Unknown Host Error

After installing Android Studio, I got the following error: Unknown host 'services.gradle.org'. Please ensure the host name is correct. If you are behind an HTTP proxy, please configure the proxy settings either in Android Studio or Gradle. Consult IDE log for more details (Help | Show Log) Solution File --> Settings --> HTTP Proxy --> Auto-detect proxy settings