如何快速找到已经实现的方法?

How to quickly find a method that has already been implemented?

我是新人javaprogrammer.At刚开始,我在项目里写了一个convert Integer List to int[]的方法

public int[] convertToArray(List<Integer> list) {
        int[] array = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            array[i] = list.get(i);
        }
        return array;
    }
后来发现GuavaInts.toArray已经实现了这个逻辑,它使用泛型,比我的write.Guava要好得多,或者Apache commons有很多API,我记不住了它的。 所以,我想知道有没有一种方法,当我想写一些逻辑时,它可以告诉我 "Hey , the Guava or Apache commons XXX Class XXX method has already implement this logic ,just use it ,Stop Trying to Reinvent the Wheel"?

去过很多次。花了几个小时写了一段逻辑才发现它已经通过库实现了。

您可以做的一件事是 google 如果您要编写任何实用程序函数(如您问题中的函数),您将要实现的目标。您很可能会找到一两个图书馆。

另一种方法是阅读 Apache Commons、Guava 等著名库的文档

没有更简单的方法。