变量
//数据类型 变量名=值; 可以使用逗号隔开来声明多个同类型变量
public clsaa Demo08{
//类变量 static
static double salary=2500;
//实例变量:从属于对象; 如果不自行初始化,这个类型的默认值0 0.0
//布尔值:默认是false
//除了基本类型,其余的都是null;
String name;
int age;
//main 方法
public static void main(String[] args){
//局部变量:必须声明和初始化值
int i=10;
System.out.println(i);
//变量类型 变量名字=new Demo08();
Demo08 demo08=new Demo08();
System.out.println(Demo08.age);
System.out.println(Demo08.name);
//类变量 static
System.out.println(salary);
}
}
public class Demo09{
//修饰符,不存在先后顺序
static final double PI=3.14;
public static void main(String[] args){
System.out.println(PI);
}
}
/*
A=0011 1100
B=0000 1101
A&B=0000 1100
A|B=0011 1101
A^B=0011 0001 异或:相同为0 不同为1
~B=1111 0010 取反:与上面相反
(2*8怎么运算最快) 2*8=16 2*2*2*2
<<左移 :乘2
>>右移 :除2 效率极高!!!
0000 0000 0
0000 0001 1
0000 0010 2
0000 0011 3
0000 1000 8
0001 0000 16
*/
System.out.println(2<<3);
public static void main(String[] args) {
//x?y:z
//如果x==true,则结果为y否则为z
int score =50;
String type=score<60?"不及格":"及格";
System.out.println(type);
}
//导入这个包下所有的类
impurt com.dfk.aaa.*;
//*通配符
package com.dfk.bbb;
/**
* @author dkf
* @version 1.0
* @since 1.8
*/
public class text7 {
String name;
/**
* @author dkf
* @param name //参数
* @return
* @throws Exception
*/
public String text(String name) throws Exception{
return name;
//通过命令行生成 javadoc 参数 java文件
//学会查找使用IEDA生成JavaDoc文档!
//面向百度编程!
}
}