·ÖÏíJavaÃæÊÔÖÐÓöµ½µÄһЩ¾µäËã·¨ÌâÄ¿
1.дһ¸ö·½·¨£¬ÓÃÒ»¸öforÑ»·´òÓ¡¾Å¾Å³Ë·¨±í
/**
* ´òÓ¡¾Å¾Å³Ë·¨¿Ú¾÷±í
*/
public void nineNineMulitTable(){
for (int i = 1,j = 1; j <= 9; i++) {
System.out.print(i+"*"+j+"="+i*j+" ");
if(i==j){
i=0;
j++;
System.out.println();
}
}
}
2.¸ø¶¨Ò»¸öjava.util.Date¶ÔÏó£¬ÈçºÎת»¯Îª”2007-3-22 20:23:22”¸ñʽµÄ×Ö·û´®
/**
* ½«Ä³¸öÈÕÆÚÒԹ̶¨¸ñʽת»¯³É×Ö·û´®
* @param date
* @return str
*/
public String date2FormatStr(Date date)
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String str = sdf.format(date);
return str;
}
3.дһ¸ö·½·¨£¬Äܹ»ÅжÏÈÎÒâÒ»¸öÕûÊýÊÇ·ñËØÊý
/**
* ÅжÏÈÎÒâÒ»¸öÕûÊýÊÇ·ñËØÊý
* @param num
* @return boolean
*/
public boolean isPrimeNumber(int num)
{
for (int i = 2; i <= Math.sqrt(num); i++) {
if(num%i==0)
{
return false;
}
}
return true;
}
4.дһ¸ö·½·¨£¬ÊäÈëÈÎÒâÒ»¸öÕûÊý£¬·µ»ØËüµÄ½×³Ë
/**
*»ñµÃÈÎÒâÒ»¸öÕûÊýµÄ½×³Ë
*@param n
*@returnn!
*/
public int factorial(int num)
{
//µÝ¹é
if(num == 1)
{
return 1;
}
return num*factorial(num-1);
}
5.дһ¸ö·½·¨£¬Óöþ·Ö²éÕÒ·¨ÅжÏÈÎÒâÕûÊýÔÚÈÎÒâÕûÊýÊý×éÀïÃæÊÇ·ñ´æÔÚ£¬Èô´æÔھͷµ»ØËüÔÚÊý×éÖеÄË÷ÒýλÖ㬲»´æÔÚ·µ»Ø-1
/**
*¶þ·Ö²éÕÒÌØ¶¨ÕûÊýÔÚÕûÐÍÊý×éÖеÄλÖÃ(µÝ¹é)
*@param dataset
*@param data
*@param beginIndex
*@param endIndex
*@return index
*/
public int binarySearch(int[] dataset,int data,int beginIndex,int endIndex){
int midIndex = (beginIndex+endIndex)/2;
//Èç¹û²éÕÒµÄÊýÒª±È¿ªÊ¼Ë÷ÒýµÄÊý¾ÝҪС»òÕßÊDZȽ
Ïà¹ØÎĵµ£º
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
public class DealFile {
/**
* ɾ³ýÎļþ
......
java exception ½â¾ö·½°¸ - ÎÒµÄÒì³£Íø|Òì³£|exception|myexception 831 - ActionMessages 832 - could not instantiate id generator 833 - javax.servlet.jsp.JspException 834 - javax.naming.NoInitialContextException 835 - net.sf.hibernate.HibernateException 836 - org.hibernate.exception.GenericJDBCExceptio ......
Ò». ×î³£¼ûµÄannotation
@Override:ÓÃÔÚ·½·¨Ö®ÉÏ£¬ÓÃÀ´¸æËß±ðÈËÕâÒ»¸ö·½·¨ÊǸÄд¸¸ÀàµÄ
@Deprecated:½¨Òé±ðÈ˲»ÒªÊ¹ÓþɵÄAPIµÄʱºòÓõÄ,±àÒëµÄʱºò»áÓòúÉú¾¯¸æÐÅÏ¢,¿ÉÒÔÉ趨ÔÚ³ÌÐòÀïµÄËùÓеÄÔªËØÉÏ.
@SuppressWarnings:ÔÝʱ°ÑһЩ¾¯¸æÐÅÏ¢ÏûÏ¢¹Ø±Õ
@Entity:±íʾ¸ÃÀàÊǿɳ־û¯µÄÀà
¶þ. Éè¼ÆÒ»¸ö×Ô¼ºµÄAnno ......
¡¡¡¡1¡¢JDK £¨Java Development Kit£© ¡¡¡¡SUNµÄJava²»½öÌáÁËÒ»¸ö·á¸»µÄÓïÑÔºÍÔËÐл·¾³£¬¶øÇÒ»¹ÌáÁËÒ»¸öÃâ·ÑµÄJava¿ª·¢¹¤¾ß¼¯(JDK)¡£¿ª·¢ÈËÔ±ºÍ×îÖÕÓû§¿ÉÒÔÀûÓÃÕâ¸ö¹¤¾ßÀ´¿ª·¢java³ÌÐò¡£ ¡¡¡¡JDK¼òµ¥Ò×ѧ£¬¿ÉÒÔͨ¹ýÈκÎÎı¾±à¼Æ÷£¨È磺Windows ¼Çʱ¾¡¢UltrEdit¡¢Editplus¡¢FrontPageÒÔ¼°dreamweaverµÈ£©±àдJavaÔ´Îļþ£¬ ......