[英]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 我是一名新的Java程序员。一开始,我在我的项目中编写了一种将Integer List转换为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; }
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. 另一种方法是阅读著名库(如Apache Commons,Guava等)的文档。
There aren't any easier ways. 没有更简单的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.