javaµÝ¹éʵÀý
example£º Çó5µÄ½×³Ë¡£¡£
ÈçÏ£º
public class Test {
static int multiply(int n){
if(n==1||n==0)
return n;
else
return n*multiply(n-1);
}
public static void main(String[] args){
System.out.println(multiply(10));
}
}
ÉÏÃæµÄmultiplyÊÇÒ»¸ö½×³ËµÄÀý×Ó¡£ÆäʵµÝ¹éµÝ¹é£¬´Ó×ÖÃæÉϽâÊ;ÍÊÇÔÚ·½·¨±¾Éíµ÷ÓÃ×Ô¼ºµÄ·½·¨£¬»òÕß¼ä½Óµ÷Ó㻿´ÉÏÃæµÄ³ÌÐò£¬ÄÃmultiply(5)À´Ëµ£º
n=5;Ö´ÐÐ 5*multiply(4);
--------------------
Õâʱºò¿´multiply(4)
n=4 Ö´ÐÐ 4*multiply(3);
-------------------
¿´multiply(3)
n=3,Ö´ÐÐ 3*multiply(2);
---------------
mulitply(2);
n=2 Ö´ÐÐ 2*mulitply(1);
Õâʱºò£¬return 1;ÍùÉÏ·µ»Ø
2*1ÏòÉÏ·µ»Ø
3*(2*1)ÏòÉÏ·µ»Ø
4*£¨3*£¨2*1£©£© ÏòÉÏ·µ»Ø
5*£¨4*£¨3*£¨2*1£©£© £© = 120
ËùÒÔ³ÌÐòÊä³ö120;
Õâʼòµ¥µÄµÝ¹éµÄÀý×Ó£»ËùÒÔ¿ÉÒÔ¿´³öÀ´µÝ¹éµÄ¹Ø¼üµÃÓеݹé³ö¿Ú(±¾ÌåµÄIfÓï¾ä)£¬»¹Óеݹ鷽·¨£»
Ïà¹ØÎĵµ£º
1. Õ»(stack)Óë¶Ñ(heap)¶¼ÊÇJavaÓÃÀ´ÔÚRamÖдæ·ÅÊý¾ÝµÄµØ·½¡£ÓëC++²»Í¬£¬Java×Ô¶¯¹ÜÀíÕ»ºÍ¶Ñ£¬³ÌÐòÔ±²»ÄÜÖ±½ÓµØÉèÖÃÕ»»ò¶Ñ¡£
¡¡¡¡2. Õ»µÄÓÅÊÆÊÇ£¬´æÈ¡ËٶȱȶÑÒª¿ì£¬½ö´ÎÓÚÖ±½ÓλÓÚCPUÖеļĴæÆ÷¡£µ«È±µãÊÇ£¬´æÔÚÕ»ÖеÄÊý¾Ý´óСÓëÉú´æÆÚ±ØÐëÊÇÈ·¶¨µÄ£¬È±·¦Áé»îÐÔ¡£ÁíÍ⣬ջÊý¾Ý¿ÉÒÔ¹ ......
»·¾³JDK1.5
Eclipse 3.2
Ö±½ÓÉÏ´úÂ룺Èç¹ûûÓÐÅäÖúû·¾³Çë²Î¿´Ç°Á½ÆªÈÕÖ¾
·þÎñÆ÷¶Ë´úÂë
UserÀࣺ
/*
*Class User.java
*Create Date: 2009-11-4
*Author:a276202460
*/
package com.axis.pojo.test;
public class User implements java.io.Serializable{
public boolean equals(Object obj) {
if (obj == ......
1. package book.io;
2.
3. import java.io.File;
4.
5. /**
6. *
7. * @author XWZ
8. * 20 ......
JDK1.4ÖÐ
Map map = new HashMap();
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
Object key = entry.getKey();
Object value = entry.getValue();
}
JDK1.5ÖÐ,Ó¦ÓÃÐÂÌØÐÔFor-EachÑ»·
Map m = new HashMap();
......