java開發中常用到小方法

2021-08-02 14:13:47 字數 1073 閱讀 4077

arraylist轉陣列

/*

* 獲取優惠券全部策略id string

*/private

string getstrategyidarraycache() throws exception ;

int rightstype = businessemun.rightstype.優惠券.getvalue();

listresultlist = cachemanagement.rightslistcache.getdata(rightstype);

if (resultlist != null && resultlist.size() > 0)

if (list.size() > 0)

}return strarray;

}

驗證是否在string arr範圍內

/**

* 驗證是否在string arr範圍內

* *@title: iscontains

*@description: todo

*@param

*@return

*@throws

*/private

boolean

iscontains(string arr, string targetvalue)

根據屬性名獲取屬性值

/**

*@title: getfieldvaluebyname

*@description: 根據屬性名獲取屬性值

*@param obj:需要查詢的物件,fieldname:物件屬性

*@return 得到結果物件

*@throws

*/private object getfieldvaluebyname(object obj, string fieldname) );

object value = method.invoke(obj, new object{});

return value;

} catch (exception e)

}

java 開發中常用方法

從list中拿出top指的條數資料 我有幾張阿里雲幸運券分享給你,用券購買或者公升級阿里雲相應產品會有特惠驚喜哦!把想要買的產品的幸運券都領走吧!快下手,馬上就要搶光了。取top x條產品類資料 param sourlist 產品類集合 param rowscount 條數 return list ...

Java中常用到的轉義字元

1.八進位制轉義序列 1到3位5數字 範圍 000 377 0 空字元 2.unicode轉義字元 u 四個十六進製制數字 0 65535 u0000 空字元 3.特殊字元 就3個 雙引號 單引號 反斜線 4.控制字元 5個 單引號字元 反斜槓字元 r 回車 n 換行 f 走紙換頁 t 橫向跳格 b...

Java中常用到的演算法題

1.遍歷出乙個資料夾下的所有檔案,並展示出層級關係,資料夾優先顯示,最後以一定格式寫入文字中 遞迴實現 遍歷出乙個資料夾下的所有檔案,並展示出層級關係,資料夾優先顯示,最後以一定格式寫入文字中 param args public static void main string args privat...