JAVA編寫陣列的工具類

2021-07-27 04:46:53 字數 921 閱讀 8080

public

class

arraytool

/*** 獲取整形陣列的最大值

* *@return

*/public

static

intgetmax(int array)

}return array[maxindex];

}/**

* 對陣列進行選擇排序

*/public

static

int selectsort(int array) }}

return array;

}// 將陣列轉換成字串,格式是:[a1,a2....an]

public

static string arraytostring(int array) else

}return str;

}// 用於陣列內容的替換

public

static

int swap(int array, int i, int j)

// 獲取指定的元素所在的索引

public

static

intgetindex(int array, int key)

system.out.println(i);

}return -1;

}public

static

void

main(string args) ));

system.out.println(arraytool.arraytostring(arraytool

.selectsort(new

int )));

system.out.println(arraytool.getindex(new

int , 2));

}}

Java工具類 Java檔案工具類

public class fileutils 讀取檔案並作為byte返回 param file 目標檔案 return throws ioexception public static byte readfileasbytes file file throws ioexception 讀取檔案並作為...

Cookie工具類的編寫

cookie並不是它的原意 甜餅 的意思,而是乙個儲存在客戶機中的簡單的文字檔案,這個檔案與特定的 web 文件關聯 在一起,儲存了該客戶機訪問這個web 文件時的資訊,當客戶機再次訪問這個 web 文件時這些資訊可供該文件使用,由於 cookie 具有可以儲存在客戶機上的神奇特性,因此它可以幫助我...

java的工具類

public class test 嚴謹的來說.是比較的記憶體位址.當你建立兩個變數物件並且賦值的時候.系統會為你在記憶體中開闢兩塊記憶體空間.他們的位址是不一樣的.就是比位址.當你new時.只要物件值不是null那麼他們永遠都是false.要比較值的使用.可用用object下的.equals ob...