首页 > 编程语言 >Java 基础 - 黑马

Java 基础 - 黑马

时间:2024-07-14 20:54:46浏览次数:10  
标签:arr Java String 基础 System 线程 IO println 黑马

String API

stringApi

ArrayList

arrayList

Enum

enum

Object

object

object2

StringBuilder

stringBuilder

StringBuffer

stringBuffer

StringJoiner

stringJoiner

Math

math

System

system

public class Main {
    public static void main(String[] args) {
//      1.  System.exit(0);//不要这样玩
//      2.  currentTimeMills: long -> 1970-1-1 0:0:0 1s=1000ms 可做性能测试
        long beforeLoop = System.currentTimeMillis();
        for (int i = 0; i < 1000000; i++) {
        }
        long afterLoop = System.currentTimeMillis();
        System.out.println((afterLoop - beforeLoop) / 1000.0 + "s");//0.002s
    }
}

Runtime

runtime

BigDecimal

big

Date

date

SimpleDateFormat

simpleDateFormat


    Date date = new Date();
    long timeMills = date.getTime();
    String formatDemo = "yyyy年MM月dd日 HH:mm:ss EEE a";
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(formatDemo);
    String finalTime1 = simpleDateFormat.format(timeMills);
    String finalTime2 = simpleDateFormat.format(date);
    System.out.println(finalTime1);//2024年07月13日 10:43:48 周六 上午
    System.out.println(finalTime2);

parseSimpleDateFormat

String dataStr = "2022-12-12";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date d2 = sdf.parse(dateStr);

Calendar

Calendar

    Calendar now = Calendar.getInstance();
    now.add(Calendar.YEAR, 1);
    now.set(Calendar.DAY_OF_MONTH, 10);

jdk8 之前的 DateError

DateError

newDate

newDate

LocalDate LocalTime LocalDateTime

newDate2

LocalDate

LocalDate

LocalTime

LocalTime

ZoneId

ZoneId

Instant

Instant

DataTimeFormatter

dataTimeFormatter

    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");

    LocalDateTime now = LocalDateTime.now();
    String rs = formatter.format(now);//正向格式化

    System.out.println(now);//2024-07-13T11:40:56.861149700
    System.out.println(rs);//2024年07月13日

    String rs2 = now.format(formatter);//反向格式化
    System.out.println(rs2);//2024年07月13日


    DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
    String dateStr = "2024年07月13日 12:12:11";
    LocalDateTime ldt = LocalDateTime.parse(dateStr, formatter2);
    System.out.println(ldt);

Period

Period

Duration

Duraton

Duration period 作用

作用

Arrays

Arrays

arrays compare

方法一:

Arrays

方法二:

Arrays

Lambda

Lambda
Lambda
Lambda

Function Ref 方法引用

Function Ref

静态方法的引用

Function Ref

实例方法的引用

Function Ref

特定类型方法的引用

Function Ref

构造器的引用

Function Ref

排序

冒泡排序

    public static void main(String[] args) {
        int[] arr = {5, 2, 3, 1};
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - i - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);//1235
        }
    }

选择排序

switchSort

二分查找

binarySearch

Regex

regexSearch

异常 Exception

Exception

集合 Collection Map

集合分类

collectionSearch

collection 分类

collectionSearch

collection 方法

collectionSearch

collection 遍历方法

collectionSearch

lambda 遍历
collectionDemo.forEach(System.out::println);
增强 for 循环

for

Iterator hasNext()

iterators

List

list

list 遍历

list

ArrayList 底层原理

list
list
list

LinkedList 底层原理

list
可用来设计栈和队列

Set

set

hashValue 哈希值

hashValue

hashSet 底层原理

hashSEt

hashSEt

hashSEt

LinkedHashSet 底层原理

linkedhashset

TreeSet

treeset

可变参数

treeset

Collections 静态方法

col

Map 集合

map

Map 常见方法

map
map

Map 遍历

map

For 键找值

map

把键值对存为 entry 对象遍历

map

Lambda

map

hashMap 底层原理

map

Stream

初体验:

map

使用步骤

map

如何获取流

map

Stream 中间方法

map

文件操作 File IO

File

file

IO 流:读写文件数据/网络数据

File

file

初体验
file

常见方法

file
文件的创建删除等
file

文件遍历
file

案例 fileSearch

file

IO 流

IO 分类
file

IO 体系
file

FileInputStream

file

利用 read 方法一个字节一个字节的读

file
循环改造
file

利用 read[byte[],offset,len] 方法以多个字节读

file
改造
file

性能优化了但读取汉字还是会乱码

使用文件字节流一次性读完

file
file

问题:如果文件过大,则创建的字节数组也很大,可能造成内存溢出

这时可以用字符流来操作

而字节流更适合做数据的转移,如文件复制

FileOutputStream

file
append = true -> 追加管道
file

文件复制

file

Try-Catch-Finally 释放资源

file

Try-With-Resources 释放资源

file

FileReader

file

读的两种方式

file

FileWriter

file

总结

file

IO-缓冲流

file

BufferedInputStream

file
file

BufferedReader

file
file

BufferedWriter

file
file

IO-转换流

出现原因:代码编码和被读文件编码不同,出现乱码

InputStreamReader

file
file

OutputStreamWriter

file

IO-打印流

file

PrintStream

file

PrintWriter

file
file

打印流应用-打印重定向 setOut(ps)

file

IO-数据流

file
file
file

IO-序列流

file

file
file
file

不参与序列化 transient

file

多个对象的序列化 -> ArrayList

IO-框架

file

Commons-io

file
file
file

特殊文件 .properties xml logback

properties

file
file
file
file

xml

file

解析 xml dom4j 框架

file
file
file

使用程序拼接写入 xml

file

DTD Schema 文档 约束 xml (了解)

日志及框架

file

logback

file

file

file
file

Thread 线程

file

继承 thread

创建方法一:
file
file

多线程注意事项:

1.启动线程必须是调用 start,而不是 run

2.不要把主线程任务放到子线程之前

实现 runnable 接口

file
file

匿名内部类写法

file
file
file

利用 Callable 接口 FutureTask 类

file
file
file

线程安全问题

file

解决线程安全问题-线程同步

file

同步代码块

file

静态方法:类名.Class

多账户: this

file

同步方法

file

Lock 锁

file

线程通信

file

gaga

线程池

gaga

线程池的创建

gaga

gaga
gaga

新任务策略

gaga

Executors 工具类

gag

Executors 陷阱

gag

乐观锁 悲观锁

网络通信

两种架构 : C/S B/S

网络通信三要素

gag

IP 地址

gag
gag

gag

InetAddress

gag

Port 端口号

gag

Protocol 协议

网络上通信的设备,事先规定的连接规则,以及传输数据的规则被称为网络通信协议

gag

OSI

gag

UDP 通信

gag

DatagramSocket

gag

一发一收案例

gag

多发多收案例

gag

TCP 通信

gag

gag

gag

TCP 一对一

gag

gag
gag
gag

TCP 多对多

gag
离线处理

gag

TCP 支持与多个客户端同时通信

gag

gag
gag
gag

TCP 通过端口转发实现群聊 客户端对客户端

gag

gag
gag
gag
gag

TCP 设计一个简单的 B/S Server

gag
gag
用线程池优化
gag

配置多开

edit Configuration -> bulid and run -> modify options -> mutiple

标签:arr,Java,String,基础,System,线程,IO,println,黑马
From: https://www.cnblogs.com/alexmaodali/p/18301974

相关文章