引用数据类型
Java中用String定义字符串 只能用双引号""
与JS不同,JS可以用单引号''
拼接字符串 用 '+' 加号连接
String v1 = "张三";
System.out.println("早上好!" + v1 + ",吃饭了吗?");
除了基本数据类型,都是引用数据类型
包的命名规则
1.尽量使用全小写字母
2.尽量不要出现 $123
3.一般情况下,使用站点名的逆序
例如www.baidu.com
包名com.baidu.模块名
包名com.baidu.架构名
根据实际情况com.baidu.模块.架构.功能.xxx
Scanner 用法
public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String s = scanner.next();
    System.out.println(s);
}Scanner scanner = new Scanner(System.in); // 运用Scanner数据
scanner.next() // 来获取值
第一个小题 运用if
// 输入两个数,如果第一个数是8且第二个数是9,就打印他俩的和
// 如果其中一个是8,有一个是9,就打印两个数的差
// 如果两个数中既没有8也没有9,就分别打印两个数
public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int num1 = scanner.nextInt();
    int num2 = scanner.nextInt();
    if (num1 == 8 && num2 == 9) {
        System.out.println("num1+num2="+num1+num2);
    } else {
        if (num1==8 || num1==9 || num2==8 || num2==9) {
            int tempNum = num1-num2;
            if (tempNum < 0) {
                tempNum *=-1;
            }
            System.out.println("num1与num2相差: "+tempNum);
        } else {
            System.out.println("num1: "+num1);
            System.out.println("num2: "+ num2);
        }
    }
}
第二个小题 运用switch
/*
* 成绩管理系统
* 键盘输入成绩
* 如果成绩是60分,及格
* 如果成绩是85分,奖励一台ipad
* 如果成绩是100分,奖励一台13promax
* 其他情况,没有奖励
* */
Scanner scanner = new Scanner(System.in);
System.out.print("请输入你的成绩: ");
int score = scanner.nextInt();
String state;
switch (score) {
    case 60:
        state="及格";
        break;
    case 85:
        state="奖励一台ipad";
        break;
    case 100:
        state="奖励一台13promax";
        break;
    default:
        state="没有奖励";
        break;
}
System.out.println(state);Java 里的switch只能判断以下数据类型
整型:byte, short, int
字符型:char
String:JDK7以后的版本 包括7
枚举:JDK5以后的版本 包括5
数组
public static void main(String[] args) {
    // 数组定义 索引从0开始
    int [] arr1 = {1,2,3,4,5};
    int arr2[] = {1,2,3,4,5};
    int [] arr3 = new int[5];
    int [] arr4 = new int[]{1,2,3,4,5,6};
}数据类型的初始值
byte、short、int、long: 0
float、double: 0.0
char: " " 空格
boolean: false
string: null
int[]: null
数组最基础的运用
public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int [] arr = new int[3];
    arr[0] = scanner.nextInt();
    arr[1] = scanner.nextInt();
    arr[2] = scanner.nextInt();
    System.out.println(arr[0]);
    System.out.println(arr[1]);
    System.out.println(arr[2]);
}
3 条评论
航宝是我的你不许抢,我撒了你 航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你  航宝是我的你不许抢,我撒了你
 航宝是我的你不许抢,我撒了你 