Package Helpdoc;
/**
* This is a tool class for manipulating arrays
* @author Songyusheng
* @version v.10
*/
public class arraytool{
/**
* This is a private structure
*/
Private Arraytool () {
}
/**
* This is the way to iterate through the array, the following format is: [element 1, Element 2, Element 3, ...]
* @param arr This is the array to be traversed
*/
public static void PrintArray (int[] arr) {
for (int x=0;x<arr.length;x++) {
if (x==arr.length-1) {
System.out.println (arr[x]+ "]");
}
else {
System.out.print (arr[x]+ ",");
}
}
}
public static int Getmax (int[] arr) {
int max=arr[0];
for (int x=1;x<arr.length;x++) {
if (Arr[x]>max) {
MAX=ARR[X];
}
}
return Max;
}
/**
* Gets the index of the first occurrence of the specified element in the array, and returns 1 if the element does not exist
* @param arr element to be found
* @param value to find the element
* @return Returns the index of the element in the array and returns 1 if it does not exist
*
*/
public static int GetIndex (int[] arr,int value) {
int index=-1;
for (int x=0;x<arr.length;x++) {
if (Arr[x]==value) {
Index=x;
Break
}
}
return index;
}
}
Help documentation (Java)