is string the basic data type in Java? Basic data types in Java __java

Source: Internet
Author: User
Tags square root wrapper

Http://blog.chinaunix.net/uid-26642637-id-3235815.html

String is not a basic data type in Java. There are 8 basic data types in Java, all of which have encapsulated classes (wrapper classes), where the wrapper class of the base data type char is somewhat special and is the character class.


Java is a strongly typed language, which means that you must declare a type for each variable. In Java, there are 8 basic data types (primitive type), with 4 integers, 2 floating-point types, 1 character-type char for character cells that represent Unicode encoding, and a Boolean type to represent truth values. These underlying types are also called raw data types, which are value-passing rather than reference-passing when data is passed.

(1). Java provides four integral types:

Int 4 bytes
Short 2 bytes
Long 8 bytes
Byte 1 bytes


In Java, the scope of an integral type is independent of the machine running Java, which is related only to Java virtual machines.

(2). Java provides two floating-point types:

Float 4 bytes
Double 8 bytes

All floating-point numeric computations follow the IEEE754 specification. The following are three special floating-point values used to indicate overflow and error conditions:

Positive Infinity: double.positive_infinity

Negative Infinity: double.negative_infinity

Nan:double. NaN (not a number)

For example: A positive integer processing divided by 0 is positive infinity, and the square root of 0/0 or minus numbers is calculated as Nan.

(3). Java-Char

In Java, a unit of code described by a char type in UTF-16 encoding. It is strongly recommended that you do not use the char type in your program. Unless you are sure you want to manipulate the UTF-16 code unit. It is best to represent the strings that need to be processed in an abstract data type.

(4). Boolean type

A Boolean type has two values: false and True to determine the logical condition. The integral type and the Boolean value cannot be exchanged directly.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.