帮助文档(java)

package helpdoc;
 /**
  * 这是针对数组进行操作的工具类
  *@author 宋宇
  * @version v.10
  */
public class  arraytool{
 /**
  * 这是私有构造
  */
 private arraytool(){
  
 }
 /**
  * 这是遍历数组的方法,遍历后的格式是: [元素1,元素2,元素3,……]
  * @param arr 这是要被遍历的数组
  */
 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;
 }
 /**
  * 获取指定元素在数组中第一次出现的索引,如果元素不存在,就返回-1
  * @param arr 被查找的元素
  * @param  value 要查找的元素
  * @return 返回元素在数组中的索引,如果不存在就返回-1
  *  
  */
 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;
 }

 
}

原文地址:https://www.cnblogs.com/rong123/p/7586580.html