Javase----basic data types and other basic understanding①

Javase----basic data types and other basic understanding①

Very suitable for zero-based learning! ! !
Let me talk about (such as the title) simple basic things today.

binary, decimal

Before talking about it, you can understand some underlying things. Here is the website for everyone to understand the conversion between bases.
Website: Click I can see the system

type of data

Data types are divided into: basic data types and reference data types
Add it down and write: basic data types and corresponding packaging types .

Basic data types (from small to large): byte short int long folat double char boolean

Packaging type (corresponding to the basic data type): Byte Short Integer Long Float Double Character boolean

Corresponding number of bytes (except boolean): 1 2 4 8 4 8 2 1

Note: Except for basic data types and String (constant pool), all are reference data types

//int转Integer
int a=3;
Integer A=Integer.valueOf(a);//由此可见int封装成integer用的是valueof()

//Integer转int
Integer A=new Integer(5);
int a=A.intValue();//由此可见解封装用的方法为intValue()

operator

Symbols: +, -, *, / can be seen in the code for specific usage.

//“+”
int a=1;
a=a+1;

//“-”
int a=2;
a=a-1;

//“*”
int a=1;
a=a*2;

//“/”
int a=1;
a=a/1; //此处a为1,如果有分母为1.0 则,结果应为1.0。

Note: (Here, integer can be understood as int) "/" If the denominator and numerator are both integers, the final result will be rounded. If there is a type larger than int, the final result is a large type. There is also a "%" which is the remainder.

int a=15;
int b=7;
system.out.print(a%b);//最后打印出来的为1

*Finally, let me tell you the difference between =, ==, ===?
=: Assignment
==: Comparison (constant area and stack comparison)
===: Compare addresses and compare values

Knowledge expansion:

Stack and heap (you can understand it, and I will write it later).
Stack Explanation Diagram
Look at the picture above,
the characteristics of the stack: 1. First in, last out.
Objects are stored in the heap, and a memory is allocated for each new object stack. Although the two objects from new are the same, they are also two different objects with different addresses (what is an object and what is a stack will be described later)

This is my first blog, I hope I can stick to it.

Guess you like

Origin blog.csdn.net/qq_41554115/article/details/97182952