Ultimate Java Part 1 Fundamentals

https://www.oracle.com/cn/java/technologies/javase/jdk11-archive-downloads.html

1. getting start

1- Setting Up the Development Environment–[koudaizy.com]



2- Anatomy of a Java Program–[koudaizy.com]

3- Your First Java Program–[koudaizy.com]


Main.java

package com.example;

public class Main {
    public static void main(String[] args) {
        System.out.println("hello world!");
    }
}

运行

java Main.java

4- How Java Code Gets Executed–[koudaizy.com]


javac Main.java


在根目录(src)下运行,输入全类名(相对src的路径,/改为.)xx.xx.xx

javac Main.java
java com.example.Main

如果没有src目录,则无需指定package,编译后也可以不用全类名

javac Main.java
java Main

5- 5 Interesting Facts about Java–[koudaizy.com]



6- Course Structure–[koudaizy.com]


2.1 Types

2- Variables–[koudaizy.com]

package com.example;
public class Main {
    public static void main(String[] args) {
        // 变量指向一段内存,类型指定变量的内存大小,=是将右侧的值赋(存)给左侧
        int age = 30;
        // 也可以同时声明多个,但是不推荐
        int ega = 2, eag = 1;
        // 重新赋值,修改
        age = 35;
        // 将age的值赋给别的变量
        int age2 = age;
        System.out.println(age2);
    }
}


  目录