Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : java

³õ̽javaÄÚ´æ»úÖÆ_¶ÑºÍÕ»

³õ̽javaÄÚ´æ»úÖÆ_¶ÑºÍÕ»
ÎÊÌâµÄÒýÈ룺
ÎÊÌâÒ»£º
String str1 = "abc";
String str2 = "abc";
System.out.println(str1==str2); //true
ÎÊÌâ¶þ£º
String str1 =new String ("abc");
String str2 =new String ("abc");
System.out.println(str1==str2); // false
ÎÊÌâÈý£º
String s1 = "ja";
String s2 = "va";
String s3 = "java";
String s4 = s1 + s2;
System.out.println(s3 == s4);//false
System.out.println(s3.equals(s4));//true
ÓÉÓÚÒÔÉÏÎÊÌâÈÃÈ˺¬ºý²»Ç壬ÓÚÊÇÌØµØËѼ¯ÁËһЩÓйØjavaÄÚ´æ·ÖÅäµÄ×ÊÁÏ,ÒÔÏÂÊÇÍøÕª£º
Java ÖеĶѺÍÕ»
Java°ÑÄÚ´æ»®·Ö³ÉÁ½ÖÖ£ºÒ»ÖÖÊÇÕ»Äڴ棬һÖÖÊǶÑÄÚ´æ¡£
ÔÚº¯ÊýÖж¨ÒåµÄһЩ»ù±¾ÀàÐ͵ıäÁ¿ºÍ¶ÔÏóµÄÒýÓñäÁ¿¶¼ÔÚº¯ÊýµÄÕ»ÄÚ´æÖзÖÅä¡£
   µ±ÔÚÒ»¶Î´úÂë¿é¶¨ÒåÒ»¸ö±äÁ¿Ê±£¬Java¾ÍÔÚÕ»ÖÐΪÕâ¸ö±äÁ¿·ÖÅäÄÚ´æ¿Õ¼ä£¬µ±³¬¹ý±äÁ¿µÄ×÷ÓÃÓòºó£¬Java»á×Ô¶¯ÊͷŵôΪ¸Ã±äÁ¿Ëù·ÖÅäµÄÄÚ´æ¿Õ¼ä£¬¸ÃÄÚ´æ¿Õ¼ä¿ÉÒÔÁ¢¼´±»Áí×÷ËûÓá£
   ¶ÑÄÚ´æÓÃÀ´´æ·ÅÓÉnew´´½¨µÄ¶ÔÏóºÍÊý×é¡£
   ÔÚ¶ÑÖзÖÅäµÄÄڴ棬ÓÉJavaÐéÄâ»úµÄ×Ô¶¯À¬»ø»ØÊÕÆ÷À´¹ÜÀí¡£
   ÔÚ¶ÑÖвúÉúÁËÒ»¸öÊý×é»ò¶ÔÏóºó£¬»¹¿ÉÒ ......

Java notify() and notifyAll() test


Java´úÂë
final TC[] ts = new TC[20];   
        for (int i = 0; i < ts.length; i++) {   
            TC target = new TC("TC " + i, SYNC1);   
            Thread thread = new Thread(target);   
            ts[i] = target;   
            thread.start();   
}  
final TC[] ts = new TC[20];
for (int i = 0; i < ts.length; i++) {
TC target = new TC("TC " + i, SYNC1);
Thread thread = new Thread(target);
ts[i] = target;
thread.start();
......

java·ºÐÍÏê½â

·ºÐÍ£¨Generic type »òÕßgenerics£©ÊÇ¶Ô Java ÓïÑÔµÄÀàÐÍϵͳµÄÒ»ÖÖÀ©Õ¹£¬ÒÔÖ§³Ö´´½¨¿ÉÒÔ°´ÀàÐͽøÐвÎÊý»¯µÄÀà¡£¿ÉÒÔ°ÑÀàÐͲÎÊý¿´×÷ÊÇʹÓòÎÊý»¯ÀàÐÍʱָ¶¨µÄÀàÐ͵ÄÒ»¸öռλ·û£¬¾ÍÏñ·½·¨µÄÐÎʽ²ÎÊýÊÇÔËÐÐʱ´«µÝµÄÖµµÄռλ·ûÒ»Ñù¡£
¿ÉÒÔÔÚ¼¯ºÏ¿ò¼Ü£¨Collection framework£©Öп´µ½·ºÐ͵͝»ú¡£ÀýÈ磬MapÀàÔÊÐíÄúÏòÒ»¸öMapÌí¼ÓÈÎÒâÀàµÄ¶ÔÏ󣬼´Ê¹×î³£¼ûµÄÇé¿öÊÇÔÚ¸ø¶¨Ó³É䣨map£©Öб£´æÄ³¸öÌØ¶¨ÀàÐÍ£¨±ÈÈçString£©µÄ¶ÔÏó¡£
ÒòΪMap.get()±»¶¨ÒåΪ·µ»ØObject£¬ËùÒÔÒ»°ã±ØÐ뽫Map.get()µÄ½á¹ûÇ¿ÖÆÀàÐÍת»»ÎªÆÚÍûµÄÀàÐÍ£¬ÈçÏÂÃæµÄ´úÂëËùʾ£º
Map m = new HashMap();
m.put("key", "blarg");
String s = (String) m.get("key");
ÒªÈóÌÐòͨ¹ý±àÒ룬±ØÐ뽫get()µÄ½á¹ûÇ¿ÖÆÀàÐÍת»»ÎªString£¬²¢ÇÒÏ£Íû½á¹ûÕæµÄÊÇÒ»¸öString¡£µ«ÊÇÓпÉÄÜijÈËÒѾ­ÔÚ¸ÃÓ³ÉäÖб£´æÁ˲»ÊÇStringµÄ¶«Î÷£¬ÕâÑùµÄ»°£¬ÉÏÃæµÄ´úÂ뽫»áÅ׳öClassCastException¡£
ÀíÏëÇé¿öÏ£¬Äú¿ÉÄÜ»áµÃ³öÕâÑùÒ»¸ö¹Ûµã£¬¼´mÊÇÒ»¸öMap£¬Ëü½«String¼üÓ³Éäµ½StringÖµ¡£Õâ¿ÉÒÔÈÃÄúÏû³ý´úÂëÖеÄÇ¿ÖÆÀàÐÍת»»£¬Í¬Ê±»ñµÃÒ»¸ö¸½¼ÓµÄÀàÐͼì²é²ã£¬¸Ã¼ì²é²ã¿ÉÒÔ·ÀÖ¹ÓÐÈ˽«´íÎóÀàÐ͵ļü»òÖµ±£´æÔÚ¼¯ºÏÖС£Õâ¾ÍÊÇ·ºÐÍËù×öµÄ¹¤×÷¡£ ......

java¶¯Ì¬µ÷ÓÃÀà

package tf;
public class TestPack {
public static void main(String [] args)
{
try
{
IAnimal cAnimal = new bird();
cAnimal.shout();
IAnimal animal =(IAnimal)java.lang.Class.forName("tf.bird").newInstance();
animal.shout();
}
catch (Exception e) {
// TODO: handle exception
}
}
}
//tf.bird ¼ÓÉϰüÃû
//bird.java
package tf;
public class bird implements IAnimal{
public void shout()
{
System.out.println("c c jiji ");
}
}
//IAnimal.java
package tf;
public interface IAnimal {
public void shout();
}
c c jiji
c c jiji ......

javaÏ̳߳ØThreadPoolExecut

JDK1.5ÖеÄÏ̳߳Ø(java.util.concurrent.ThreadPoolExecut
6
ÍÆ¼ö
ÔÚ¶àÏ̴߳óʦDoug LeaµÄ¹±Ï×Ï£¬ÔÚJDK1.5ÖмÓÈëÁËÐí¶à¶Ô²¢·¢ÌØÐÔµÄÖ§³Ö£¬ÀýÈ磺Ï̳߳ء£
Ò»¡¢¼ò½é
Ï̳߳ØÀàΪ java.util.concurrent.ThreadPoolExecutor£¬³£Óù¹Ôì·½·¨Îª£º
ThreadPoolExecutor(int corePoolSize, int maximumPoolSize,
long keepAliveTime, TimeUnit unit,
BlockingQueue<Runnable> workQueue,
RejectedExecutionHandler handler)
corePoolSize£º Ï̳߳ØÎ¬»¤Ï̵߳Ä×îÉÙÊýÁ¿
maximumPoolSize£ºÏ̳߳ØÎ¬»¤Ï̵߳Ä×î´óÊýÁ¿
keepAliveTime£º Ï̳߳ØÎ¬»¤Ïß³ÌËùÔÊÐíµÄ¿ÕÏÐʱ¼ä
unit£º Ï̳߳ØÎ¬»¤Ïß³ÌËùÔÊÐíµÄ¿ÕÏÐʱ¼äµÄµ¥Î»
workQueue£º Ï̳߳ØËùʹÓõĻº³å¶ÓÁÐ
handler£º Ï̳߳ضԾܾøÈÎÎñµÄ´¦Àí²ßÂÔ
Ò»¸öÈÎÎñͨ¹ý execute(Runnable)·½·¨±»Ìí¼Óµ½Ï̳߳أ¬ÈÎÎñ¾ÍÊÇÒ»¸ö RunnableÀàÐ͵ĶÔÏó£¬ÈÎÎñµÄÖ´Ðз½·¨¾ÍÊÇ RunnableÀàÐͶÔÏóµÄrun()·½·¨¡£
µ±Ò»¸öÈÎÎñͨ¹ýexecute(Runnable)·½·¨ÓûÌí¼Óµ½Ï̳߳ØÊ±£º
Èç¹û´ËʱÏ̳߳ØÖеÄÊýÁ¿Ð¡ÓÚcorePoolSize£¬¼´Ê¹Ï̳߳ØÖеÄÏ̶߳¼´¦ÓÚ¿ÕÏÐ״̬£¬Ò²Òª´´½¨ÐµÄÏß³ÌÀ´´¦Àí±»Ìí¼ÓµÄÈÎÎñ¡£
Èç¹û´ËʱÏ̳߳ØÖеÄÊýÁ¿µÈÓÚ corePoolSize£¬µ«ÊÇ» ......

Lesson1 Foundations of java and oo programming

Today , i take the first lesson of java ,let me sum up the details:
firstly,about jdk and jre.jdk stands for java development kit,while jre represent java Runtime Environment. jdk is the key of Java. And,jvm(java virtual machine) is the key of jre.
then ,about the platform independence of java.During the runing process of the java process,we should firstly compile the *.java source process,and generate the *. class file,and then bytecode,then run it by the jvm.This process make java be platform independence.
finally,the first java program----hello world
public class Hello{
 public static void main(String args[]){
  String str = "hello world!";
  System.out.println("\"hello world!\"\t"  +  "+\t"  + str);
 }
};
then i look up sth about the bytecode,the information is below:
ÕâÒ»Á½Ä꣬ÔÚJVMÉÏʹÓÃÆäËûÌæ´úÓïÑÔÔ½À´Ô½ÈÈÃÅÁË¡£ÏÖÔÚÖÁÉÙÓÐÈýÃÅÓïÑÔÓÐÐÒÔÚJava Community ProcessÖеõ½Á˹ٷ½ÈϿɣºJRuby¡¢GroovyºÍBean-Shell¡£ÁíÍ⣬´ú ......
×ܼǼÊý:6386; ×ÜÒ³Êý:1065; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [559] [560] [561] [562] 563 [564] [565] [566] [567] [568]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ