java读书笔记

int age =15;person someone;
强类型语言
变量必须声明,并且初始化以后使用
变量必须有明确的类型
变量不能重复定义

变量的初始化 第一次赋值
public class VarDemo{
public static void main(String[] args){
int age;//变量的声明
//System.out.println(age);错误,读取了未初始化的变量
age = 12;//变量的初始化,第一次赋值
age = 13;//变量的赋值
System.out.peintln(age);//访问,读取变量的值
//System.out.println(score);//错误,还没定义
int score = 122;//直接声明并且初始化
Systm.out.println(score);//122
//int score = 111;//错误 变量不能重复定义
score = 211;//赋值
System.out.println(score);//211
if(score>11){
int iq = 111;
System.out.println(iq);
}
//System.out.println(iq);//错误
int iq = 200 //不是重复定义,if语句中的iq已经释放了
System.out.println(iq);//200
if(isMan){
System.out.println("爷们来了");
}
}
}
format 格式化
int i = 15;//00000000 00000000 00000000 00001111
char c ='a';//00000000
Binary 二进制
String 字符串

public class BinDemo{
public static void main(String[] args){
int I = 15;
System.out.println(Integer.toBinaryString(i));//1111
i = 'A'
System.out.println(Integer.toBinaryString(i));
/*
1111(2)=1*2^3+1*2^2+1*2^1+1*2^0
=15(10)
二进制的权:128 64 32 16 8 4 2 1
16进制 0-9,a-f:0-15
基数:16 权:16^2 16^1 16^0:256 16 1
41(16) =4*16+1*1=65
c0(16) = 12*16+0*1=192
*/
i = Oxc0;//Ox代表16进制,c0= 15 0
i=Oxffff ;
System.out.println(integer.toBinary(i));
i = Oxaaaa;
System.out.println(integer.toBinaryString(i));
i='中';//Ox4e2d=='中'
System.out.println(Integer.toBinaryString(i));
}
}

/*
c 0
8421 8421

1100 0000

f f
8421 8421
1111 1111

*/
//5M(1024*1024)(Byte)
//1Byte = 8 bit= 两位16进制表示
//5M=1024*1024*2个16进制字符
整数类型:
byte 8bit -128to127
shot 16bit -32768to32767
int 32bit -2Gto2G-1
long 64bit
浮点类型 float double
字符类型 char
布尔类型 boolean
alt F11 然后再project右键插入模块,然后黏贴下面
Sub Macro()
Mywidth = 4.13
Myheigth = 5.69
For Each iShape In ActiveDocument.InlineShapes
iShape.Height = 28.345 * Myheigth
iShape.Width = 28.345 * Mywidth
Next iShape
End Sub
再按F5运行
0110pm

pulic class IntegerDemo{
public static void main(String[] args){
int age =20;
System.out.println()
}
}





相关文档
最新文档