JavaÖеÄequals·½·¨ºÍ==ÔËËã
ÖµÀàÐÍÊÇ´æ´¢ÔÚÄÚ´æÖеĶÑÕ»£¨ÒÔºó¼ò³ÆÕ»£©£¬¶øÒýÓÃÀàÐ͵ıäÁ¿ÔÚÕ»Öнö½öÊÇ´æ´¢ÒýÓÃÀàÐͱäÁ¿µÄµØÖ·£¬¶øÆä±¾ÉíÔò´æ´¢ÔÚ¶ÑÖС£==²Ù×÷±È½ÏµÄÊÇÁ½¸ö±äÁ¿µÄÖµÊÇ·ñÏàµÈ£¬¶ÔÓÚÒýÓÃÐͱäÁ¿±íʾµÄÊÇÁ½¸ö±äÁ¿ÔÚ¶ÑÖд洢µÄµØÖ·ÊÇ·ñÏàͬ£¬¼´Õ»ÖеÄÄÚÈÝÊÇ·ñÏàͬ¡£equals²Ù×÷±íʾµÄÁ½¸ö±äÁ¿ÊÇ·ñÊǶÔͬһ¸ö¶ÔÏóµÄÒýÓ㬼´¶ÑÖеÄÄÚÈÝÊÇ·ñÏàͬ¡£
==±È½ÏµÄÊÇ2¸ö¶ÔÏóµÄµØÖ·£¬¶øequals±È½ÏµÄÊÇ2¸ö¶ÔÏóµÄÄÚÈÝ¡£
ÏÔÈ»£¬µ±equalsΪtrueʱ£¬==²»Ò»¶¨Îªtrue£»
Ò»¡¢StringÖеÄequalsºÍ==
1¡¢
public class TestString {
public static void main(String[] args) {
String s1 = "Monday";
String s2 = "Monday";
}
}
ÉÏÃæÕâ¶Î³ÌÐòÖУ¬µ½µ×Óм¸¸ö¶ÔÏóÄØ£¿
À´¼ì²âһϰɣ¬ÉÔ΢¸Ä¶¯Ò»Ï³ÌÐò
public class TestString {
public static void main(String[] args) {
String s1 = "Monday";
String s2 = "Monday";
if (s1 == s2)
System.out.println("s1 == s2");
else
System.out.println("s1 != s2");
}
}
±àÒë²¢ÔËÐгÌÐò£¬Êä³ö£ºs1 == s2
˵Ã÷£ºs1 Óë s2 ÒýÓÃͬһ¸ö String ¶ÔÏó -- "Monday"!
2.
ÔÙÉÔ΢¸Ä¶¯Ò»Ï³ÌÐò£¬»áÓиüÆæ¹ÖµÄ·¢ÏÖ£º
public class TestString {
public static void main(String[] args) {
String s1 = "Monday";
String s2 = new String("Monday");
if (s1 == s2)
System.out.println("s1 == s2");
else
System.out.println("s1 != s2");
if (s1.equals(s2))
System.out.println("s1 equals s2");
else
System.out.println("s1 not equals s2");
}
}
ÎÒÃǽ« s2 Óà new ²Ù×÷·û´´½¨
³ÌÐòÊä³ö£º
s1 != s2
s1 equals s2
˵Ã÷£ºs1 s2·Ö±ðÒýÓÃÁËÁ½¸ö"Monday"String¶ÔÏó
3. ×Ö·û´®»º³å³Ø
ÔÀ´£¬³ÌÐòÔÚÔËÐеÄʱºò»á´´½¨Ò»¸ö×Ö·û´®»º³å³Ø
µ±Ê¹Óà s2 = "Monday" ÕâÑùµÄ±í´ïÊÇ´´½¨×Ö·û´®µÄʱºò£¬³ÌÐòÊ×ÏÈ»á
ÔÚÕâ¸öString»º³å³ØÖÐÑ°ÕÒÏàֵͬµÄ¶ÔÏó£¬ÔÚµÚÒ»¸ö³ÌÐòÖУ¬s1Ïȱ»
·Åµ½Á˳ØÖУ¬ËùÒÔÔÚs2±»´´½¨µÄʱºò£¬³ÌÐòÕÒµ½Á˾ßÓÐÏàֵͬµÄ s1
½« s2 ÒýÓà s1 ËùÒýÓõĶÔÏó"Monday"
µÚ¶þ¶Î³ÌÐòÖУ¬Ê¹ÓÃÁË new ²Ù×÷·û£¬ËûÃ÷°×µÄ¸æËß³ÌÐò£º
"ÎÒÒªÒ»¸öеģ¡²»Òª¾ÉµÄ£¡"ÓÚÊÇÒ»¸öеÄ"Monday"Sting¶ÔÏó±»´´
½¨ÔÚÄÚ´æÖС£ËûÃǵÄÖµÏàͬ£¬µ«ÊÇλÖò»Í¬£¬Ò»¸öÔÚ³ØÖÐÓÎÓ¾
Ò»¸öÔÚ°¶±ßÐÝÏ¢¡£°¥Ñ½£¬ÕæÊÇ×ÊÔ´ÀË·Ñ£¬Ã÷Ã÷ÊÇÒ»ÑùµÄ·ÇÒª·Ö¿ª×öʲôÄØ£¿
4.
Ôٴθü¸Ä³ÌÐò£º
public class TestString {
public static void main(String[] a
Ïà¹ØÎĵµ£º
1.JAVAÁ¬½ÓACCESSÊý¾Ý¿â
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ="+application.getRealPath("/Data/ReportDemo.mdb");
Connection conn = DriverManager.getConnection(url,"","");
ÔÚÉÏÃæµÄÁ¬½Ó·½·¨ÖУ¬ËùÉæ¼°µ½µÄ²ÎÊýº¬ÒåÈçÏÂËùʾ ......
1.servlet²úÉúÑéÖ¤Â룺
package com.servlet;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import javax.imageio.ImageIO; ......
ÏÂÃ濪½²¹ÊÊ£º
´ÓÇ°Óиö·¿¼ä£¬·¿¼äÀïÓзÝÎĵµ£¬·¿¼ä»¹ÓÐÒ»°ÑÔ¿³×¡£ Õâ°ÑÔ¿³×ÔÚÕÅÈýÊÖÀï¡£
ÕâʱÀîËÄÀ´ÏòÕÅÈýÒªÄÇ·ÝÎĵµ¡£ ÕÅÈý²»Ì«Ï²»¶ÀîËÄ£¬µ«ÓÖŵ¢ÎóÁË
¹¤×÷²»ºÃ½»´ú¡£ÓÚÊÇÕÅÈý¾Í°Ñ·¿¼äÀïÎĵµµÄÎĵµ¸´Ó¡ÁËÒ»·Ý£¬È»ºó°ÑÄǸö¸´Ó¡¼þ½»¸øÁËÀîËÄ£¨Õâ½Ð´«Öµ£©¡£
ÀîËÄÄõ½Îĵµºó£¨¸´Ó¡¼þ£©£¬ºúÂÒÐÞ¸ÄÒ» ......
package thread;
class TestThread extends Thread {
public void run(){
while(true){
System.out.println(Thread.currentThread().getName());
}
}
}
public class ThreadDemo {
/**
* @param args
*/
public static void ......
£¨×¢£ºÇ°ÃæдÁËÒ»¸ö³¬´óÕûÊýÏà¼ÓµÄÀ࣬²Î¼û£º ³¬´óÕûÊýÏà¼Ó£¬³¬¹ýÁËlongµÄ·¶Î§£¬ÄãÒªÔõô×ö£¡£¬ºóÀ´ÓÐÅóÓÑÆÀÂÛ˵BigDecimal¿ÉÒÔÍêȫʵÏÖÎÒµÄÕâÕâ¸ö¹¦ÄÜ£¬¸Õ¿ªÊ¼µÄʱºò£¬ÎÒ»¹²»·þÆø£¬¾ÝÎÒËùÖªÄÇÀïÓÐÕâÑùµÄÀàŶ£¬ºóÀ´±¨×Å˵·þËûµÄÐÄÀíÈ¥ÕÒÁËһϣ¬ºÇºÇ£¬½á¹û¾ÓÈ»×Ô¼º±»Ëµ·þÁË£¬È·ÊµÓÐÕâôһ»ØÊ£¬ÀûÓÃBigDecimal²Ù×÷³¬´óÕûÊýÒ ......