gpt4 book ai didi

java - 我如何查看 Java 进行了哪些优化

转载 作者:行者123 更新时间:2023-12-02 07:02:37 27 4
gpt4 key购买 nike

我有以下代码

 public boolean matches(String word) {

Pattern p = Pattern.compile("\\w$");
Matcher m = p.matcher(word);
return m.find();

}

我想知道java编译器是否用对象替换Pattern.compile("\w$")短语,或者在每次调用函数时创建对象。

我怎样才能知道java对我的代码做了什么?
有没有一个 eclipse 插件可以显示这个?

最佳答案

根据源代码,每次调用函数时都会创建对象。

public static Pattern compile(String regex) {
return new Pattern(regex, 0);
}

关于java - 我如何查看 Java 进行了哪些优化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16462092/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com