龙空技术网

学习知多少:java篇

LearningYard学苑 154

前言:

当前大家对“basicjava”大致比较看重,兄弟们都想要剖析一些“basicjava”的相关资讯。那么小编也在网上搜集了一些有关“basicjava””的相关文章,希望大家能喜欢,姐妹们快快来了解一下吧!

分享兴趣,传播快乐,增长见闻,留下美好!

亲爱的您,这里是LearningYard学苑。今天小编为大家带来“学习知多少:java篇”,欢迎您的访问。

Share interests, spread happiness, increase knowledge, and leave a good legacy!

Dear you, this is The LearningYard Academy. Today Xiaobian brings you "Learn how much to know :Java chapter”, welcome your visit.

一、思维导图

一、 Mind mapping

二、基本数据类型(中)

二、 Basic Data Type (Part 2)

1、内置数据类型

1. Built-in data type

Java语言提供了八种基本类型。其中包括六种数字类型(四个整数型,两个浮点型),一种字符类型,还有一种布尔型。

The Java language provides eight basic types. There are six numeric types (four integer types, two floating point types), one character type, and one Boolean type.

(1)byte:

byte 数据类型是8位、有符号的,以二进制补码表示的整数;范围是 -128(-2^7)到 127(2^7-1);byte 类型用在大型数组中节约空间,主要代替整数,因为 byte 变量占用的空间只有 int 类型的四分之一。

(1)byte:

The byte data type is an 8-bit signed integer represented by a binary complement; The range is - 128 (- 2 ^ 7) to 127 (2 ^ 7-1); The byte type is used in large arrays to save space, mainly replacing integers, because the byte variable occupies only a quarter of the space of the int type.

(2)short:

short 数据类型是 16 位、有符号的以二进制补码表示的整数范围是 -32768(-2^15)到 32767(2^15 - 1);Short 数据类型也可以像 byte 那样节省空间。一个short变量是int型变量所占空间的二分之一。

(2)short:

The short data type is a 16 bit signed integer represented by a binary complement in the range of - 32768 (- 2 ^ 15) to 32767 (2 ^ 15 - 1); The Short data type can also save space like byte. A short variable is half the space occupied by an int variable.

(3)int:

int 数据类型是32位、有符号的以二进制补码表示的整数;范围是 -2,147,483,648(-2^31)到2,147,483,647(2^31 - 1);一般地整型变量默认为 int 类型。

(3)int:

The int data type is a 32-bit signed integer represented by a binary complement; The range is - 2147483648 (- 2 ^ 31) to 2147483647 (2 ^ 31 - 1); Generally, integer variables are of type int by default.

(4)long:

long 数据类型是 64 位、有符号的以二进制补码表示的整数;这种类型主要使用在需要比较大整数的系统上。

(4)long:

The long data type is a 64 bit signed integer represented by a binary complement; This type is mainly used on systems that require larger integers.

(5)float:

float 数据类型是单精度、32位、符合IEEE 754标准的浮点数;float 在储存大型浮点数组的时候可节省内存空间;浮点数不能用来表示精确的值,如货币。

(5)float:

The float data type is a single precision, 32-bit, floating point number that conforms to the IEEE 754 standard; Float can save memory space when storing large floating point arrays; Floating point numbers cannot be used to represent precise values, such as currency.

(6)double:

double 数据类型是双精度、64 位、符合 IEEE 754 标准的浮点数;浮点数的默认类型为 double 类型;double类型同样不能表示精确的值,如货币。

(6)double:

The double data type is a double precision, 64 bit, IEEE 754 compliant floating point number; The default type for floating point numbers is double; The double type cannot also represent precise values, such as currency.

(7)boolean:

boolean数据类型表示一位的信息;只有两个取值:true 和 false;这种类型只作为一种标志来记录 true/false 情况。

(7)boolean:

The Boolean data type represents one bit of information; There are only two values: true and false; This type is only used as a flag to record true/false situations.

(8)char:

char 类型是一个单一的 16 位 Unicode 字符;char 数据类型可以储存任何字符。

(8)char:

The char type is a single 16 bit Unicode character; The char data type can store any character.

2、引用类型

在Java中,引用类型的变量非常类似于C/C++的指针。引用类型指向一个对象,指向对象的变量是引用变量。这些变量在声明时被指定为一个特定的类型,比如 Employee、Puppy 等。变量一旦声明后,类型就不能被改变了。对象、数组都是引用数据类型。所有引用类型的默认值都是null。一个引用变量可以用来引用任何与之兼容的类型。

2. Reference Type

In Java, variables of reference type are very similar to pointers in C/C++. The reference type refers to an object, and the variable pointing to the object is a reference variable. These variables are specified as a specific type when declared, such as Employee, Puppy, and so on. Once a variable is declared, its type cannot be changed. Objects and arrays are reference data types. The default value for all reference types is null. A reference variable can be used to reference any compatible type.

3、符号

字符含义

\n 换行 (0x0a)

\r 回车 (0x0d)

\f 换页符(0x0c)

\b 退格 (0x08)

\0 空字符 (0x0)

\s 空格 (0x20)

\t 制表符

\" 双引号

\' 单引号

\\ 反斜杠

\ddd 八进制字符 (ddd)

\uxxxx 16进制Unicode字符 (xxxx)

3. Symbols

Character Meaning

\N Line feed (0x0a)

\R Enter (0x0d)

\F Page feed character (0x0c)

\B Backspace (0x08)

\0 null character (0x0)

\S space (0x20)

\T Tab

\"Double quotation marks

\'Single quotation mark

\\Backslash

\Ddd octal character (ddd)

\Uxxxx hexadecimal Unicode character (xxxx)

今天的分享就到这里了。

如果您对今天的文章有独特的想法,

欢迎给我们留言,

让我们相约明天。

祝您今天过得开心快乐!

That's all for today's sharing.

If you have a unique idea for today’s article,

please leave us a message,

and let us meet tomorrow.

I wish you a happy day !

本文由learningyard新学苑原创,如有侵权,请联系我们!

翻译来源于谷歌翻译

部分来源于

百度文库

清华大学出版《java程序设计基础》

编辑&排版|百味

审核|闫庆红

标签: #basicjava