08-常用-api

1. API

Application programming interface 应用程序编程接口(别人写好的程序,自己可以直接调用)

称自己为,API 调用工程师, 提高了开发效率。

API 文档(应用程序编程接口文档,程序的说明书)

#TODO

assets/01-入门/08-常用-api/IMG-20250520-012542-122.png

2. 包

描述类的位置。语法 package 包名;

例如: package com.juna; 类的位置在操作系统实际目录结构 com/juna 文件夹。

导包语法 import 包名.类名; 例如:

import com.jun.*;
import com.bao.Student

//常用包
//java.lang
//java.util
//java.io
//......

注意点:

3. String

String 是引用数据类型。

package com.juna;  
  
public class Demo {  
    public static void main(String[] args) {  
        String a = "app";  //1 常量池 "app"
        String b = "apple";  //2 常量池 “apple”
        String c = "app" + "le";  //和 b 引用同一个常量池字中的字符串对象 
        String d = new String("apple");  //3 堆  
        String e = new String("apple");  //4 堆  
        String f = a + "le";   //5 堆  
  
        //内存中创建了几个字符串对象?5个  
        System.out.println(b == c); // true  
        System.out.println(b == d); // false  
        System.out.println(b == e); // false  
        System.out.println(b == f); // false  
        System.out.println(e == f); // false  
    }  
}

3.1. 常用 API


3.2. 案例

3.2.1. 用户登录


3.2.2. 用 String 开发验证码


4. ArrayList

4.1. 常用 API


4.2. 案例


4.2.1. 从容器找数据并成功删除


4.2.2. 模仿外卖系统的商家系统


上一节:07-面向对象编程基础
下一节:09-demo-atm