IDEA debug HashMap source code experience

public static void main(String[] args) {
        //test();
        HashMap<String,String> hashMap = new HashMap<>();
        for (int i = 0; i < 10; i++) {
            hashMap.put("name","wang");
            hashMap.put("name","wan");
        }

    }

1. If you only break the point at put, the execution process will not enter the HashMap source code

 2. If both put and HashMap's putVal are interrupted at the same time, the execution will first enter the putVal interrupt point, which is not the debug process that you want to see. Because not only HashMap is called by itself, jdk, but also many jars are called, and other jars are called before the calls in main.

 3. Solution

First break the point at the main, then debug, and after running to the main, add the endpoint in the HashMap source code

 

Guess you like

Origin blog.csdn.net/xiaowang_lj/article/details/129316010