易截截图软件、单文件、免安装、纯绿色、仅160KB

Java的求质数

package stone;
public class PrimerNumber {
public static void main(String[] args) {
int MAX_NUMBER = 100;
boolean[] notPrimer= new boolean[MAX_NUMBER];
for(int i=2;i<=MAX_NUMBER;i++){
if(!notPrimer[i-1]){
for(int j=2*i;j<=MAX_NUMBER;j++){
if(j%i==0) notPrimer[j-1]=true;
}
}
}
for(int i=0;i<MAX_NUMBER;i++){
if(!notPrimer[i]) System.out.print(i+1+" ");
}
}
}
 
运行结果如下:
1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97


相关文档:

JAVA常用操作语句 项目中的总结三


获得mysql和oracle链接的类
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectDB {
private static final String MYSQL = "jdbc:mysql://";
private static final String ORACLE = "jdbc:oracle:thin:@";
private ConnectD ......

[Java Generics] get T.Class from T

 
/**
 * Copyright (c) 2010 IBOBO Corporation. All Rights Reserved.
 */
package com.ibm.util.dao.hib;
/**
 * [Java Generics] get T.Class from <T>
 * 
 * @author <a ......

Java得到mac地址

/*
* GetMacAddress .java
*
* description:get Mac addreess
*
* @author hadeslee
*
* Created on 2007-9-27, 9:11:15
*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test2; 
import java.io.BufferedReader; 
import java.io.IO ......

JAVA常用操作语句 项目中的总结六


判断一个文件是否为二进制文件
public static boolean isBinary(File file) {
boolean isBinary = false;
try {
FileInputStream fin = new FileInputStream(file);
long len = file.length();
  for (int j = 0; j < (int) len; j++) {
int t = fin.read();
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号