Help documentation (Java)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.