java ¶þ·Ö·¨
public class Test4 {
public int binarySearch(int[] items, int value){
int startIndex = 0;
int stopIndex = items.length - 1;
int middle = (int)Math.floor((stopIndex + startIndex)/2);
while(items[middle] != value && startIndex < stopIndex){
//adjust search area£¨µ÷Õû²éÕÒ·¶Î§£©
if (value < items[middle]){
stopIndex = middle - 1;
} else if (value > items[middle]){
startIndex = middle + 1;
}
//recalculate middle£¨ÖØмÆËãÖÐÏîË÷Òý£©
middle = (int)Math.floor((stopIndex + startIndex)/2);
}
//make sure it's the right value£¨È·±£·µ»ØÕýÈ·µÄÖµ£©
return (items[middle] != value) ? -1 : middle;
}
/**
* @param args
*/
public static void main(String[] args) {
Test4 t = new Test4();
int aa[]={1,3,5,7,9};
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!"+t.binarySearch(aa, 5));
}
}
Ïà¹ØÎĵµ£º
For Ubuntu 10.04 LTS, the sun-java6 packages have been dropped from the Multiverse section of the Ubuntu archive. It is recommended that you use openjdk-6 instead.
If you can not switch from the proprietary Sun JDK/JRE to OpenJDK, you can install sun-java6 packages from the Canonical Partner Reposi ......
Ó¢ÎÄÔÎĵØÖ·:
http://www.onjava.com/pub/a/onjava/2005/07/06/generics.html
ÖÐÎĵØÖ·:
http://www.matrix.org.cn/resource/article/43/43634_java_generics.html
¹Ø¼ü´Ê£º java generics java5
ÕªÒª
·ºÐÍÊÇJ2SE 5.0×îÖØÒªµÄÌØÐÔ¡£ËûÃÇÈÃÄãдһ¸ötype(Àà»ò½Ó¿Ú£©ºÍ´´½¨Ò»¸ö ......
JavaÖÐÌṩÁ˷ḻµÄÈÕÆÚ±íʾ·½Ê½¡£ÆäÖаüÀ¨Date¡¢Timestamp¡¢Calendar¡¢GregorianCalendarÀà¡£GregorianCalendarÀàÖÐÌṩÁËÓÃÓÚ¼ÆËãÈÕÆÚµÄadd()·½·¨£¬¿ÉÒԺܷ½±ãµØ¼ÆËãÈô¸ÉÄê¡¢Ô¡¢ÈÕºóµÄÈÕÆÚ¡£
¸ø¸öÀý×Ó¿´¿´£º
package testjava;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import ......
һЩÎÞÁĵĴúÂëÖ®Ò»£ºJAVAÖеÄÈÕÆÚ¼ÆËã
/*
* DateCalculate.java , Created on 2005-3-18
* Copyright 2005 AAA Information Technology CO.LTD. All rights reserved.
*
* ×÷³ÉÈÕÆÚ: 2005-3-18
* ÐÞ¸ÄÂÄÀú:
*
*/
package com.bjb.xyh.util;
import java.text.DecimalFormat;
//import java.text.Pars ......
À´×Ôhttp://www.ilovematlab.cn/thread-30836-1-1.html
matlab java.lang.OutOfMemoryError
JavaÐéÄâ»úÄÚ´æ²»¹»ÓÃÁË.¿ÉÒÔÔö¼Ó×î´óÄÚ´æÉèÖÃ.
1. ²éÕÒmatlab¸ù·¾¶.ÔÚmatlabÃüÁîÐÐÖÐÇÃÈë:matlabroot
ÏÔʾ¸ù·¾¶,Èç:C:\MATLAB7
2.²é¿´µ±Ç°JavaÐéÄâ»ú×î´ó¶ÑÄÚ´æ, ÇÃÈë:java.lang.Runtime.getRuntime.maxMemory
3.²é¿ ......