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

JavaÖеÄÅÅÐò±È½Ï·½Ê½£º×ÔÈ»ÅÅÐòºÍ±È½ÏÆ÷ÅÅÐò

¡¡¡¡ÕâÀïËù˵µ½µÄJavaÖеÄÅÅÐò²¢²»ÊÇÖ¸²åÈëÅÅÐò¡¢Ï£¶ûÅÅÐò¡¢¹é²¢ÅÅÐòµÈ¾ßÌåµÄÅÅÐòËã·¨¡£¶øÊÇÖ¸Ö´ÐÐÕâЩÅÅÐòË㷨ʱ£¬±È½ÏÁ½¸ö¶ÔÏó“´óС”µÄ±È½Ï²Ù×÷¡£ÎÒÃǺÜÈÝÒ×Àí½âÕûÐ굀 i>j ÕâÑùµÄ±È½Ï·½Ê½£¬µ«µ±ÎÒÃǶԶà¸ö¶ÔÏó½øÐÐÅÅÐòʱ£¬ÈçºÎ±È½ÏÁ½¸ö¶ÔÏóµÄ“´óС”ÄØ£¿ÕâÑùµÄ±È½Ï stu1 > stu2 ÏÔÈ»ÊDz»¿ÉÄÜͨ¹ý±àÒëµÄ¡£ÎªÁ˽â¾öÈçºÎ±È½ÏÁ½¸ö¶ÔÏó´óСµÄÎÊÌ⣬JDKÌṩÁËÁ½¸ö½Ó¿Ú java.lang.Comparable ºÍ java.util.Comparator ¡£
Ò»¡¢×ÔÈ»ÅÅÐò£ºjava.lang.Comparable
¡¡¡¡Comparable ½Ó¿ÚÖÐÖ»ÌṩÁËÒ»¸ö·½·¨£º compareTo(Object obj) £¬¸Ã·½·¨µÄ·µ»ØÖµÊÇ int ¡£Èç¹û·µ»ØÖµÎªÕýÊý£¬Ôò±íʾµ±Ç°¶ÔÏó(µ÷Óø÷½·¨µÄ¶ÔÏó)±È obj ¶ÔÏó“´ó”£»·´Ö®“С”£»Èç¹ûΪÁãµÄ»°£¬Ôò±íʾÁ½¶ÔÏóÏàµÈ¡£ÏÂÃæÊÇÒ»¸öʵÏÖÁË Comparable ½Ó¿ÚµÄ Student Àࣺ
public class Student implements Comparable {
private int id;

private String name;
public Student() {
super();
}
@Override
public int compareTo(Object obj) {
if (obj instanceof Student) {
Student stu = (Student) obj;
return id - stu.id;
}
return 0;
}
@Override
public String toString() {
return "<" + id + ", " + name + ">";
}
}
¡¡¡¡Student ʵÏÖÁË×ÔÈ»ÅÅÐò½Ó¿Ú Comparable £¬ÄÇôÎÒÃÇÊÇÔõôÀûÓÃÕâ¸ö½Ó¿Ú¶ÔÒ»×é Student ¶ÔÏó½øÐÐÅÅÐòµÄÄØ£¿ÎÒÃÇÔÚѧϰÊý×éµÄʱºò£¬Ê¹ÓÃÁËÒ»¸öÀàÀ´¸øÕûÐÍÊý×éÅÅÐò£º java.util.Arrays ¡£ÎÒÃÇʹÓà Arrays µÄ sort ·½·¨À´¸øÕûÐÍÊý×éÅÅÐò¡£·­·­ API Îĵµ¾Í»á·¢ÏÖ£¬ Arrays Àï¸ø³öÁË sort ·½·¨ºÜ¶àÖØÔØÐÎʽ£¬ÆäÖоͰüÀ¨ sort(Object[] obj) £¬Ò²¾ÍÊÇ˵ Arryas Ò²ÄܶԶÔÏóÊý×é½øÐÐÅÅÐò£¬ÅÅÐò¹ý³ÌÖбȽÏÁ½¸ö¶ÔÏó“´óС”ʱʹÓõľÍÊÇ Comparable ½Ó¿ÚµÄ compareTo ·½·¨¡£
public class CompareTest {
public static void main(String[] args) {
Student stu1 = new Student(1, "Little");
Student stu2 = new Student(2, "Cyntin");
Student stu3 = new Student(3, "Tony");
Student stu4 = new Student(4, "Gemini");

Student[] stus = new Student[4];
stus[0] = stu1;
stus[1] =


Ïà¹ØÎĵµ£º

JavaµÄʱ¼ä´¦Àí(Ðø)

¸ÅÊö
Èç¹ûÄãÖªµÀÔõÑùÔÚjavaÖÐʹÓÃÈÕÆÚ£¬ÄÇôʹÓÃʱ¼äºÍËü²Å²»¶àÒ»Ñù¼òµ¥¡£ÕâÆªÎÄÕ¸æËßÄãÔõÑù°ÑËûÃǵIJî±ðÁªÏµÆðÀ´¡£Robert Nielsen»¹¸æËßÄãÔõÑùʹÓÃjavaÀ´¼ÆËãµÖ´ïº½°àºÍÖÆÔì¹ý³ÌµÄʱ¼ä¡£
×÷ÕߣºRobert Nielsen
·­Ò룺Cocia Lin
ÕâÆªÎÄÕÂÊÇÔÚÎÒ·¢±í¹ýµÄ<¼ÆËãJavaʱ¼ä>(ÒëÕß:ÒѾ­·­ÒëÍê³É)µÄ»ù´¡Éϵġ£ÔÚÕâÀΠ......

Java Swing·ÂQQµÇ¼½çÃæ ѧϰ֮ÓÃ

ÏÐÀ´ÎÞʽ«ÔçЩʱºòÒÑʵÏÖµÄQQµÇ¼½çÃæÔÙʵÏÖÁËÒ»±é£¬´¿ÊÖ¹¤´òÔ죨Òâ˼ÊÇûÓÐÓÃNetBeans¡¢MyEclipseµÄÍ϶¯¹¦ÄÜ£©¡£
Ô´´úÂëÈçÏ£º
 package ibees.qq;
import java.awt.BorderLayout;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import j ......

×îÖØÒªµÄ Java EE ×î¼Ñʵ¼ù 2. ²»Òª×öÖØ¸´µÄ¹¤×÷¡£


2. ²»Òª×öÖØ¸´µÄ¹¤×÷¡£
ʹÓó£¼ûµÄ¡¢¾­¹ý֤ʵµÄ¿ò¼Ü£¬Èç Apache Struts¡¢JavaServer Faces ºÍ Eclipse RCP¡£Ê¹Óþ­¹ý֤ʵµÄģʽ¡£
»Øµ½ÎÒÃÇ¿ªÊ¼°ïÖú¿Í»§Ê¹ÓøճöÏÖµÄ Java EE ±ê×¼µÄʱºò£¬ÎÒÃÇ·¢ÏÖ£¨ºÍÐí¶àÆäËûÈËÒ»Ñù£©£¬Í¨¹ýÖ±½ÓʹÓûù´¡µÄ Servlet ºÍ JSP ¹æ·¶¹¹½¨ UI Ó¦ÓóÌÐòÀ´¿ª·¢Óû§½Ó¿Ú¿ª·¢¿ò¼Ü£¬¿ÉÒÔ¼«´óµØÌḠ......

JavaÀíÂÛÓëʵ¼ù:ÕýȷʹÓÃvolatile±äÁ¿

Java™ÓïÑÔ°üº¬Á½ÖÖÄÚÔÚµÄͬ²½»úÖÆ£ºÍ¬²½¿é£¨»ò·½·¨£©ºÍvolatile±äÁ¿¡£ÕâÁ½ÖÖ»úÖÆµÄÌá³ö¶¼ÊÇΪÁËʵÏÖ´úÂëÏ̵߳ݲȫÐÔ¡£ÆäÖÐvolatile±äÁ¿µÄͬ²½ÐԽϲµ«ÓÐʱËü¸ü¼òµ¥²¢ÇÒ¿ªÏú¸üµÍ£©£¬¶øÇÒÆäʹÓÃÒ²¸üÈÝÒ׳ö´í¡£ÔÚÕâÆÚµÄJavaÀíÂÛÓëʵ¼ùÖУ¬Brian Goetz½«½éÉܼ¸ÖÖÕýȷʹÓÃvolatile±äÁ¿µÄģʽ£¬²¢Õë¶ÔÆäÊÊÓÃÐÔÏÞÖÆÌá³öÒ» ......

JAVA SWING ×é¼þÏÔʾ

ÔÚËùÓÐ×é¼þ¶¼·Åµ½JFrameÖ®ºó£¬ÏÈsetSize()£¬È»ºóÔÙsetVisible()   ¡£
   
ÉèÖÃÁË´°¿ÚµÄSize,²¼¾Ö¹ÜÀíÆ÷²ÅÄÜΪ¸÷¸ö×é¼þ°²ÅźÏÊʵÄλÖÃ,Ö®ºóÔÙ°Ñ´°ÌåÏÔʾ³öÀ´setVisible()£¬±ÈÈçÄ㻹²»ÖªµÀ³§·¿µÄ´óС£¬Õâʱ¾ÍÎÞ·¨¾ö¶¨É豸°²·ÅµÄλÖᣠ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ