Home > Java > javaTutorial > java built-in data types

java built-in data types

巴扎黑
Release: 2016-12-19 11:42:42
Original
1446 people have browsed it

Constant is a quantity that will not be modified when the program is running.

 Use the final keyword in Java to modify constants, and the declaration method is similar to variables:

 finaldouble PI =3.1415927;

 Although constant names can also be in lowercase, for ease of identification, capital letters are usually used to represent constants.

 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, hexadecimal and octal.

When using constants, the prefix 0 represents octal, and the prefix 0x represents hexadecimal. For example:

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

 Like other languages, Java's string constants are also character sequences contained between two quotation marks. The following are examples of string literals:

 "Hello World" "twonlines" ""This is in quotes""

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

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

 Java language supports some special escape character sequences.

Symbol                                                                               through Enter(0x0d)
f Backspace(0x08)
s Space (0x20)
t Tab character
" Double quotes
' Single quote
\                                                                                                                                                                                                            Backslash Hexadecimal Unicode characters (xxxx)



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template