编程语言
首页 > 编程语言> > JAVA基础学习第一题

JAVA基础学习第一题

作者:互联网

# JAVA数据类型

![image-20210721145457416](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721145457416.png)![image-20210721145522253](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721145522253.png)

## 字节回顾



![image-20210721145847778](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721145847778.png)

## 进制回顾,及进制面试

![image-20210721150151436](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721150151436.png)

## 字符拓展

![image-20210721150706273](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721150706273.png)

![image-20210721150742813](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721150742813.png)

## 布尔值的拓展

![image-20210721151157674](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721151157674.png)

## 强制转换

![image-20210721151756685](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721151756685.png)



从高到低时需要强制转换

![image-20210721151830856](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721151830856.png)

## 一些小补充

![image-20210721152126638](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721152126638.png)

1.为了方便。可以在数字之间加下划线,值并不会变。

---



2.计算某些值要防止溢出。比如下面的例子

![image-20210721152321587](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721152321587.png)

得到的结果是一个负数。

---

这时候可以吧它强制转换成long类型。得到的结果就不会溢出。

![image-20210721152518093](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721152518093.png)

---



## 变量的作用域

![image-20210721153822318](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721153822318.png)

- 局部变量必须定义一个初始值。且只在当前函数方法内可用,

  ![image-20210721154014053](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721154014053.png)

---



- 实例变量,类的里面方法的外面。从属于对象。![image-20210721155220791](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721155220791.png)

![image-20210721155252555](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721155252555.png)

没有给变量赋值时默认值![image-20210721155354115](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721155354115.png)

除了八大基本类型,其他默认值都为NULL。

---

- 常量的定义

  ![image-20210721155656289](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721155656289.png)

static在final前后都能运行。

![image-20210721155745131](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721155745131.png)

---



* 变量的命名规范![image-20210721160040075](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721160040075.png)

  ## 运算符

  

* 基础运算符-关系运算符

* ![image-20210721161403835](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721161403835.png)

- 求平方![image-20210721163255731](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721163255731.png)

---



- 逻辑运算符&&(与)、||(或)![image-20210721163554397](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721163554397.png)

- 位运算<<  ,>>。与二进制相关

  <<代表左移动,相当于*2。>>向右移动相当于/2。

  比如

System.out.println("2<<3");


得到结果为8

相当于把2的二进制向左移动3位

0000 0001---->0001 000

---

三元运算符

![image-20210721164556616](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721164556616.png)

---

## JAVA中的包

![image-20210721224040493](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721224040493.png)

![image-20210721224111517](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721224111517.png)

包的命名与公司域名倒置;例:www.baidu.com创建包的名字就是com.baidu.www

包的导入用import

![image-20210721224255227](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721224255227.png)

- 这里在Demo01当中导入剩下的包可以直接import com.kuang.base.*;![image-20210721224519664](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210721224519664.png)

- 推荐看阿里巴巴开发手册,上面有基础和规则。

---

## JAVADoc命名

![image-20210722095951046](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210722095951046.png)

![image-20210722100023925](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210722100023925.png)

![image-20210722100323196](C:\Users\DNL-CZ\AppData\Roaming\Typora\typora-user-images\image-20210722100323196.png)


标签:JAVA,AppData,第一,DNL,image,typora,学习,CZ,images
来源: https://www.cnblogs.com/youngerstar/p/15049044.html