简体   繁体   中英

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

I am a new java programmer.At the beginning,i write a method convert Integer List to int[] in my project

 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; } 
Later,i found that Guava Ints.toArray has been already implemented this logic,it use generics and far better than my write.Guava or Apache commons has a lot of API and i can't remember all of it. So, i wondering is there a way that when i want to write some logic , it can tell me that "Hey , the Guava or Apache commons XXX Class XXX method has already implement this logic ,just use it ,Stop Trying to Reinvent the Wheel"?

Been there many times. Have spent hours to write a piece of logic only to find it has been already implemented through a library.

One thing you could do is to google what you are trying to achieve if you are about to write any utility function like the one in your question. Most likely you would find a library or two.

Another way would be to read the documentation of famous libraries like Apache Commons, Guava etc.

There aren't any easier ways.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM