Java¶à̬ÐÔµÄÀí½â
¶à̬µÄÄ¿µÄ
ͨ¹ýÀàÐÍת»»£¬°ÑÒ»¸ö¶ÔÏóµ±×÷ËüµÄ»ùÀà¶ÔÏó¶Ô´ý¡£
´ÓÏàͬµÄ»ùÀàÅÉÉú³öÀ´µÄ¶à¸öÅÉÉúÀà¿É±»µ±×÷ͬһ¸öÀàÐͶԴý£¬¿É¶ÔÕâЩ²»Í¬µÄÀàÐͽøÐÐͬÑùµÄ´¦Àí¡£
ÕâЩ²»Í¬ÅÉÉúÀàµÄ¶ÔÏóÏìӦͬһ¸ö·½·¨Ê±µÄÐÐΪÊÇÓÐËù²î±ðµÄ£¬ÕâÕýÊÇÕâЩÏàËƵÄÀàÖ®¼ä±Ë´ËÇø±ðµÄ²»Í¬Ö®´¦¡£
¶¯Ì¬°ó¶¨
½«Ò»¸ö·½·¨µ÷ÓúÍÒ»¸ö·½·¨Ö÷ÌåÁ¬½Óµ½Ò»Æð³ÆΪ°ó¶¨£¨Binding£©¡£
¸ù¾Ý°ó¶¨µÄʱ»ú²»Í¬£¬¿É½«°ó¶¨·ÖΪ“ÔçÆڰ󶨔ºÍ“ºóÆڰ󶨔Á½ÖÖ¡£
Èç¹ûÔÚ³ÌÐòÔËÐÐ֮ǰ½øÐа󶨣¨ÓɱàÒëÆ÷ºÍÁ´½Ó³ÌÐòÍê³É£©£¬³ÆΪÔçÆڰ󶨡£
Èç¹ûÔÚ³ÌÐòÔËÐÐÆÚ¼ä½øÐа󶨣¬³ÆΪºóÆڰ󶨣¬ºóÆÚ°ó¶¨Ò²³ÆΪ“¶¯Ì¬°ó¶¨”»ò“ÔËÐÐʱ°ó¶¨”¡£
ÔÚJavaÖУ¬¶à̬ÐÔÊÇÒÀ¿¿¶¯Ì¬°ó¶¨ÊµÏֵģ¬¼´JavaÐéÄâ»úÔÚÔËÐÐʱȷ¶¨Òªµ÷ÓÃÄÄÒ»¸öͬÃû·½·¨¡£
¶à̬µÄÓ¦ÓÃ
ÓÉÓÚ¶à̬ÐÔ£¬Ò»¸ö¸¸ÀàµÄÒýÓñäÁ¿¿ÉÒÔÖ¸Ïò²»Í¬µÄ×ÓÀà¶ÔÏ󣬲¢ÇÒÔÚÔËÐÐʱ¸ù¾Ý¸¸ÀàÒýÓñäÁ¿ËùÖ¸Ïò¶ÔÏóµÄʵ¼ÊÀàÐÍÖ´ÐÐÏàÓ¦µÄ×ÓÀà·½·¨¡£
ÀûÓöà̬ÐÔ½øÐжþ´Î·Ö·¢¡£
ÀûÓöà̬ÐÔÉè¼Æ»Øµ÷·½·¨¡£
¶à̬µÄÀý×Ó
ShapeÀàÊǼ¸¸ö¾ßÌåͼÐÎÀàµÄ¸¸Àà
package cn.edu.uibe.poly;
public class Shape {
public void draw(){
System.out.println("Shape.draw()");
}
}
RectangleÀàÊÇShapeÀàµÄÒ»¸ö×ÓÀà
package cn.edu.uibe.poly;
public class Rectangle extends Shape {
@Override
public void draw() {
System.out.println("»¾ØÐÎ");
}
}
CircleÀàÒ²ÊÇShapeÀàµÄ×ÓÀà
package cn.edu.uibe.poly;
public class Circle extends Shape{
@Override
public void draw() {
System.out.println("»Ô²");
}
}
TriangleÀàÊÇShapeÀàµÄÁíÍâÒ»¸ö×ÓÀà
package cn.edu.uibe.poly;
public class Triangle extends Shape{
@Override
public void draw() {
System.out.println("»Èý½ÇÐÎ");
}
}
ShapeDemoÀàÖÐËæ»úÉú³É¾ØÐΡ¢Ô²¡¢Èý½ÇÐΣ¬È»ºóÓÃShapeÀàÐ͵ÄÒýÓõ÷Óá£
package cn.edu.uibe.poly;
import java.util.*;
public class ShapeDemo {
Random rand = new Random();
public Shape createShape(){
int c = rand.nextInt(3);
Shape s = null;
switch(c){
case 0:
s = new Rectangle();
break;
case 1:
s = new Circle();
break;
case 2:
s = new Triangle();
break;
}
return s;
}
public static void main(
Ïà¹ØÎĵµ£º
1.µÃµ½µ±Ç°µÄʱ¼ä
Calendar cal = Calendar.getInstance();
String time=formatter.format(cal.getTime());
String strEnd=time.substring(0, 16);// 2007-10-30 09:30
2.µÃµ½Ç°Ò»ÌìµÄʱ¼ä
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_MONTH, -1);
SimpleDateFormat ......
Javaѧϰ·¾¶£¨Ò»£©¹¤¾ßƪ
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJDKÊÇSun¹«Ë¾·¢²¼µÄJDK£¬³ýÁËSunÖ®Í⣬»¹Ó ......
ÎÒѧϰjavaÒѽüÒ»Äê¶àÁË°¡£¬ºÃÏñ»¹ÊÇûѧµ½Ê²Ã´¶«¶«°¡£¬²»ÖªµÀѧºÃjavaÕÆÎÕºÃjavaµ½µ×ÀëÎÒ»¹ÓжàÔ¶°¡¡£ÏÖÔÚÎÒ¶¼Óеã×Ô±©×ÔÆúµÄ¸Ð¾õ°¡¡£Á¬Ò»°ãµÄ¶«Î÷ѧÆðÀ´ÈÃÎҺܳÔÁ¦°¡¡£·³ÄÔÖа¡£¡ÎÒ×ÜÊÇÃÎÏëÕâÎÒ³ÉΪһΪjava
¸ßÊÖ£¬¶ÔjavaÓÐÕâ¶ÀÌصÄÀí½â£¬ÓÐÕâºÃ µÄÊÕÈë¡£ÕâÒ²ÊÇ»¹Ã»·ÅÆúµÄÔÒò°¡¡£ÎÒÏëÎÒ»á³É¹¦µÄ£¬ÄÇÊdzÙÔçµÄÊ¡£ÆÚ´ýÕâÄ ......
·þÎñ¶Ë£º
package socket;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
public static void main(String[] args) {
try {
ServerSocket server = new Se ......
1.FileÀàΪ¹ÜÀíÎļþºÍĿ¼ÌṩÁË·½·¨£¬Æä¶ÔÏó±íʾһ¸öÎļþ»òÕßĿ¼¡£ËüÌṩÁËÈô¸É·½·¨¶ÔÎļþ»òÎļþ¼Ð½øÐвÙ×÷¡£ÆäÖеÄlist()·½·¨ºÍlistFiles()·½·¨¿ÉÒÔÆ𵽶¨Î»Ìض¨ÎļþµÄ×÷Óá£
2.ObjectÀ࣬ÊÇËùÓÐJavaÀàµÄ×æÏÈ£¬ÈôÒ»¸öÀàÉùÃ÷ʱûÓаüº¬extends¹Ø¼ü×Ö£¬ÔòÆäÖ±½Ó¼Ì³ÐÓÚObjetcÀà¡£ÆäÖÐÓÐÐí¶àÖØÒª·½·¨£º
equals(),not ......