Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java×÷Òµ01

package homework01;
public class TestWhile {

public static double factorial(int n) //Çó½×³Ëº¯Êý
{
if(n==0) return 1;
else return n* factorial(n-1);
}

public static void main(String[] args) {
System.out.println(factorial(170));//test:ÄÜ´òÓ¡³öÀ´£¬170Ö®ºó±ã²»ÄÜ´òÓ¡ÁË

/*1¡¢Ê¹ÓÃwhileÑ­»·¼ÆËã1-1000Ö®¼äÄܱ»3ºÍ7ͬʱÕû³ýµÄÕûÊýÖ®ºÍ*/
int count=0;//ÕûÊýÖ®ºÍ
int i=1000;
while(i>0){
if((i%3==0)&&(i%7==0)){
count+=i;
}
i--;
}
System.out.println("1-1000Ö®¼äÄܱ»3ºÍ7ͬʱÕû³ýµÄÕûÊýÖ®ºÍ:"+count);

/*2¡¢Ê¹ÓÃforÑ­»·¼ÆËã8+88+888+···µÄÇ°10ÏîÖ®ºÍ*/
long mun=0;
for(int j=0;j<10;j++){
mun+=mun+8*(Math.pow(10, j));
//System.out.println(mun); //test
}
System.out.println("8+88+888+···µÄÇ°10ÏîÖ®ºÍ:"+mun);

/* 3¡¢¼ÆËã1-1/3+1/5-1/7+···µÄÇ°10000ÏîÖ®ºÍ */
double mun2=0;
for(int n=0;n<10000;n++){
int t=(int)Math.pow(-1, n);
double p=1.0/(2.0*n+1);
mun2+=t*p;
//System.out.println(mun2);//test
}
System.out.println("1-1/3+1/5-1/7+···µÄÇ°10000ÏîÖ®ºÍ:"+mun2);

/*4¡¢¼ÆËã1+2£¡+3£¡+4£¡+···´ÓµÚ100Ïîµ½200ÏîÖ®ºÍ*/
double f=0;
for(int k=100;k<=200;k++){
f+=factorial(k);
//System.out.println(f);
}
System.out.println("1+2£¡+3£¡+4£¡+···´ÓµÚ100Ïîµ½200ÏîÖ®ºÍ:"+f);
System.out.println("Infinity±íʾÕýÎÞÇî´ó£¬¼´´óÓÚdOUbleÀàÐÍËùÄܱíʾµÄ×î´óÊýÖµ¡£¸ºÎÞÇî´ó½«Êä³ö" +
"-Infinity.\nʵ¼ÊÉÏ£¬ÈκμÆËã½á¹ûÖ»Òª³¬³ödoubleÀàÐÍËùÄܱíʾµÄ×î´óÊýÖµ£¬¾Í»á²úÉúÕâÑùµÄ½á¹û¡£");

}


}


Ïà¹ØÎĵµ£º

Java¿É±ä²ÎÊýÁбí

public class TestClass{
public static void main(String args[]){
VarArgs(1, "one");
VarArgs(2, "one", "two");
VarArgs(3, "one", "two", "three");
VarArgs(0); // Attention!
}
static void VarArgs(int nRequired, String... trailing){
System.out.print("Required: " + nRequired + " "); ......

Java Concurrent°üѧϰ֮ConcurrentHashMap

ÔÚJava concurrent°üÖÐÓÐÕâôһ¸ö½Ó¿Ú£ºConcurrentMap¡£
ConcurrentMap¼Ì³Ð×ÔMap£¬²¢Ìí¼ÓÁ˼¸¸öеÄÔ­×Ó·½·¨£º putIfAbsent¡¢remove¡¢replace
Æä·½·¨ÕªÒªÈçÏ£º
 V
putIfAbsent(K key, V value)
          Èç¹ûÖ¸¶¨¼üÒѾ­²»ÔÙÓëij¸öÖµÏà¹ØÁª£¬Ôò½ ......

Java³ÌÐò£¬Ò»¸öʵÏÖEnumerationµÄ×éºÏÀà

import java.util.Enumeration;
public class CipherTest implements Enumeration {
private int N;
private int c[], k;
private Object[] objs;
public CipherTest(Object[] items) {
N = items.length;
c = new int[N + 1];
for (int i = 0; i <= N; i++)
c[i] = i;
objs = items;
k = 1 ......

java¼¯ºÏSet²Ù×÷


package Sets;   
import java.util.HashSet;   
import java.util.Iterator;   
import java.util.Set;   
import java.util.TreeSet;   
  
/**  
 * java¼¯ºÏ²Ù×÷  
 *   
  ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ