我的问题是在整个Android API中,很多库调用要求将results[]参数传递给方法,例如:
public boolean isInProximity(double startLat, double startLongitude, float meters) {
float[] results = new float[3];
Location.distanceBetween(startLat, startLongitude, endLatitude, endLongitude, results);
return results[0] <= meters;
}
Run Code Online (Sandbox Code Playgroud)
对android的调用是Location.distanceBetween(),它需要results[]为什么他们不只是在方法中包含一个返回签名?我假设它是某种内存或速度优化.我不确定背后的确切原因.