易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : java

java:double类型截取俩位小数,不取舍,

public class Split{
 public static void main(String[] args){
       double pai = 3.14159;
        findTwo(pai);
  public static void findTwo(double value){
    System.out.println(new DecimalFormat("0.##").format(value));
}
}
} ......

java:二分查找法

package arrays.compara;
/**
 *
 * @author Happy 二分查找法
 */
public class BinarySearch {
 public static void main(String[] args) {
  int[] arrInt = { 2, 34, 32, 24, 23, 34, 12, 3, 4, 2 };
  int index = bSearch(29, arrInt, 0, arrInt.length);
  System.out.println("Index : " + index);
  /*
   * for (int i : arrInt) { System.out.println(i); }
   */
 }
 // js二分查找法(没有成功)
 private static int bSerarch(int[] arrInt, int value) {
  int startIndex = 0, stopIndex = arrInt.length - 1, middle = (int) (Math
    .floor((stopIndex + startIndex) / 2));
  while (arrInt[middle] != value && startIndex < stopIndex) {
   // adjust search area(调整查找范围)
   if (value < arrInt[middle]) {
    stopIndex = middle - 1;
   } else if (value > arrInt[middle]) {
& ......

java:Object对象进行排序

package arrays.compara;
import java.util.Arrays;
public class Student {
 public static void main(String[] args) {
  Stu[] stus = new Stu[]{
    new Stu(156,34,"ad"),
    new Stu(153,24,"cc"),
    new Stu(126,37,"ab"),
    new Stu(176,45,"as"),
    new Stu(156,34,"bd")
  };
  Arrays.sort(stus);
  for (int i = 0; i < stus.length; i++) {
   System.out.println(stus[i].toString());
  }
 }
}
class Stu implements Comparable<Object> {
 int hight;
 int age;
 String name;
 public Stu(int hight, int age, String name) {
  this.hight = hight;
  this.age = age;
  this.name = name;
 }
 //年龄比较
 /*public int compareTo(Object obj) {
  return (this.age > ((Stu)obj).age) ? 1 : (this.age == ((Stu)obj).age) ? 0 : -1;
......

java:大数据文件写入,读取,分割,排序,合并

package arrays.file;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Random;
public class ConcludeCombinationSortWrite {
 /**
  * 大数据排序合并
  *
  * @param args
  */
 public static void main(String[] args) throws IOException {
  // 写入文件的路径
  String filePath = "D:\\456";
  // 切分文件的路径
  String sqlitFilePath = "D:\\456\\123";
  //数据的个数
  int CountNumbers=10000000;
  
  //子文件的个数
  int CountFile=10;
  
  //精度
  int countAccuracy=30*CountFile;
  
  long startNumber=System.currentTimeMillis();
  // 写入大数据文件
  ......

java:经典文件写入和读取,速度超快

package arrays.file;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.Writer;
public class CreateFile {
 public static void main(String[] args) {
  // readerFile("E:/workspace6/Arrays/src/myArray/Nodes.java");
//  readerFileToo();
  //writeInMemroy();
  writeFile2();
 }
 // 经典读取数据一
 public static String readerFile() {
  // E:/workspace6/Arrays/src/myArray/Nodes.java
  String s, s2 = "";
  try {
   BufferedReader in = new BufferedReader(new FileReader
     ("E:/workspace6/Arrays/src/myArray/Nodes.java"));
   try {
&nb ......

java:手写二叉树BinaryTree添加和查询方法

package arrays.myArray;
public class BinaryTree {
 private Node root;
 // 添加数据
 public void add(int data) {
  // 递归调用
  if (null == root)
   root = new Node(data, null, null);
  else
   addTree(root, data);
 }
 private void addTree(Node rootNode, int data) {
  // 添加到左边
  if (rootNode.data > data) {
   if (rootNode.left == null)
    rootNode.left = new Node(data, null, null);
   else
    addTree(rootNode.left, data);
  } else {
   // 添加到右边
   if (rootNode.right == null)
    rootNode.right = new Node(data, null, null);
   else
    addTree(rootNode.right, data);
  }
 }
 // 查询数据
 public void show() {
  showTree(root);
 }
 priv ......
总记录数:6386; 总页数:1065; 每页6 条; 首页 上一页 [95] [96] [97] [98] 99 [100] [101] [102] [103] [104]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号