package com.sf.day02; import org.junit.Test; public class TE { public static final String IP_ADDRESS = "192.168.1.1"; @Test public void test01(){ System.out.println("Hello"); int num = 20; // int NUM = 20; } public String getUserInfo(){ return "h"; } @Test public void t2(){ int num = 10; // = == num = 20; System.out.println(num); /** * 变量 (按照数据类型进行分): * 基本数据类型: * 整型: byte short int(默认) long * 4?字节数不同 ->表数范围不同 1字节 = 8bit(计算机的最小单元) * 字节数 1 2 4 8 * 1字节 == 8bit * 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 * 2^8 = 256 *符号位 + - -->256种 包含正负 * -128--------------------0--------------------------127> * byte 表数范围 -128 +127 * short 2字节 = 16bit * 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 *2^16 --- -2^15 +2^15-1 * * * 浮点型: float double(默认) 12.3 * 4 8 * float uu = 12.3; * * 字符型: char 'a' String字符串 "ANC" * 字符和整型是可以进行运算的 ‘A’+1 = 'B' int 66 A 65 a 97 * 布尔型: boolean true 真 false 假 * * * 引用数据类型: 数组 类 接口 */ byte count = 0; long mm = 19L; long nn = 19l; float uu = 12.3F; float yy = 12.3f; double ii = 12.3D; String str = "abc"; float num1 = (float) 12.3; } /** * i++ ++i 的区别 * i++ ++i * 没有接收值: 一样的都是对变量i进行加一操作 * 有接收值: i++ 先赋值后运算 ++i先运算后赋值 */ @Test public void t3(){ int num = 10; int c = num++; // int c = ++num; System.out.println(num); System.out.println(c); } }