Java built-in data types

Source: Internet
Author: User

The amount of constants that will not be modified while the program is running.

Use the final keyword in Java to decorate a constant declaration in a way that is similar to a variable

Finaldouble PI = 3.1415927;

Although constant names can also be lowercase, uppercase letters are usually used to denote constants for easy identification.

Literals can be assigned to variables of any built-in type. For example

byte a = 68; char a = ' a '

byte, int, long, and short can all be represented in decimal, 16-binary, and 8-binary ways.

When a constant is used, the prefix 0 represents 8 binary and the prefix 0x represents 16 binary. For example

intdecimal=100; int octal = 0144; int Hexa =0x64;

As in other languages, a string constant of Java is also a sequence of characters that is contained between two quotation marks. The following is an example of a string literal

"Hello World" "Two\nlines" "\" This is in Quotes\ ""

Both string constants and character constants can contain any Unicode characters. For example

char a = ' \u0001 '; String a = "\u0001";

The Java language supports some special sequences of escape characters.

symbols character meaning
\ n Line Break (0x0a)
\ r Enter (0x0d)
\f Page Break (0x0c)
\b BACKSPACE (0x08)
\s Space (0x20)
\ t Tabs
\" Double quotes
\‘ Single quotation marks
\\ Back slash
\ddd octal character (DDD)
\uxxxx 16 Binary Unicode characters (xxxx)


Technology sharing: www.kaige123.com

This article is from the "11247808" blog, please be sure to keep this source http://11257808.blog.51cto.com/11247808/1868956

Java built-in data types

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.