JAVA常用類的使用方法

2021-04-13 08:29:55 字數 874 閱讀 6611

interger:整數型別

1、屬性。

static int max_value:返回最大的整型數;

static int min_value:返回最小的整型數;

static class type :返回當前型別。

例子:system.out.println("integer.max_value: " + integer.max_value );

結果為:integer.max_value: 2147483647

2、建構函式。

integer(int value) :通過乙個int的型別構造物件;

integer(string s) :通過乙個string的型別構造物件;

例子:integer i = new integer("1234");

生成了乙個值為1234的integer物件。

3、方法。

說明:1. 所有方法均為public;

2. 書寫格式:[修飾符] 《返回型別》 《方法名([引數列表])>

如:static int parseint(string s) 表示:此方法(parseint)為類方法(static),返回型別為(int),方法所需引數為string型別。

1. bytevalue():取得用byte型別表示的整數;

2. int compareto(integer anotherinteger) :比較兩個整數。相等時返回0;小於時返回負數;大於時返回正數。

例子:integer i = new integer(1234);

system.out.println("i.compareto: " + i.compareto(new integer(123)) );

結果為:i.compareto: 1

常用類的使用方法

常用類的使用方法 nterger 整數型別 屬性。system.out.println integer.max value integer.max value 結果為 integer.max value 2147483647 建構函式。integer i new integer 1234 生成了乙個...

Java 中 this 的使用方法

1.this是指當前物件自己。當在乙個類中要明確指出使用物件自己的的變數或函式時就應該加上this引用。如下面這個例子中 public class a public static void main string args 執行結果 s helloworld 1 this.s hello 2 thi...

vbs類的使用方法

vbs類的使用方法 類的結構 class 類名稱 end class 呼叫方法 set myclass new 類名稱 中間類裡面的 類模組的事件過程。private sub class initialize 這裡寫上類例項化的時候執行的 end sub private sub class term...