电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

java常用函数2VIP免费

java常用函数2_第1页
1/76
java常用函数2_第2页
2/76
java常用函数2_第3页
3/76
/** * 将某个日期以固定格式转化成字符串 * * @param date * @return String */ public static String dateToStr(java.util.Date date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String str = sdf.format(date); return str; } /** * 判断任意一个整数是否素数 * * @param n * @return boolean */ public static boolean isPrimes(int n) { for (int i = 2; i <= Math.sqrt(n); i++) { if (n % i == 0) { return false; } } return true; } /** * 获得任意一个整数的阶乘,递归 * * @param n * @return n! */ public static int factorial(int n) { if (n == 1) { return 1; } return n * factorial(n - 1); } /** * 将指定 byte 数组以 16 进制的形式打印到控制台 * * @param hint * String * @param b * byte[] * @return void */ public static void printHexString(String hint, byte[] b) { System.out.print(hint); for (int i = 0; i < b.length; i++) { String hex = Integer.toHexString(b[i] & 0xFF); if (hex.length() == 1) { hex = '0' + hex; } System.out.print(hex.toUpperCase() + " "); } System.out.println(""); } wait(); //线程等待 notify(); //激活一个线程/* * Db.javaCreated on 2007 年 8 月 20 日, 上午 8:37*/import java.io.*;import java.sql.*;import java.util.Properties;public class Db { private String driver; private String url; private String user; private String password; private Connection conn; private Statement stm; private ResultSet rs; public Db(){ this("DBConf.properties"); } public Db(String conf) { loadProperties(conf); setConn(); } public Connection getConn(){ return this.conn; } //handle the properties file to get the informations for connection private void loadProperties(String conf){ Properties props = new Properties(); try { props.load(new FileInputStream(conf)); } catch (FileNotFoundException e) { e.printStackTrace(); } catch ...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

java常用函数2

海纳百川+ 关注
实名认证
内容提供者

热爱教学事业,对互联网知识分享很感兴趣

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部