Èý·ÖÖÓÀí½âJavaÖÐ×Ö·û´®£¨String£©µÄ´æ´¢ºÍ¸³ÖµÔÀí
¿ÉÄܺܶàjavaµÄ³õѧÕ߶ÔStringµÄ´æ´¢ºÍ¸³ÖµÓÐÃÔ»ó£¬ÒÔÏÂÊÇÒ»¸öºÜ¼òµ¥µÄ²âÊÔÓÃÀý£¬ÄãÖ»ÐèÒª»¨¼¸·ÖÖÓʱ¼ä±ã¿ÉÀí½â¡£
1.ÔÚ¿´Àý×Ó֮ǰ£¬È·±£ÄãÀí½âÒÔϼ¸¸öÊõÓ
Õ» £ºÓÉJVM·ÖÅäÇøÓò£¬ÓÃÓÚ±£´æÏß³ÌÖ´ÐеĶ¯×÷ºÍÊý¾ÝÒýÓá£Õ»ÊÇÒ»¸öÔËÐеĵ¥Î»£¬JavaÖÐÒ»¸öÏ߳̾ͻáÏàÓ¦ÓÐÒ»¸öÏß³ÌÕ»ÓëÖ®¶ÔÓ¦¡£
¶Ñ £ºÓÉJVM·ÖÅäµÄ£¬ÓÃÓÚ´æ´¢¶ÔÏóµÈÊý¾ÝµÄÇøÓò¡£
³£Á¿³Ø £ºÔÚ¶ÑÖзÖÅä³öÀ´µÄÒ»¿é´æ´¢ÇøÓò£¬ÓÃÓÚ´æ´¢ÏÔʽ µÄString£¬float»òÕßinteger.ÀýÈçString str="abc"; abcÕâ¸ö×Ö·û´®ÊÇÏÔʽÉùÃ÷£¬ËùÒÔ´æ´¢ÔÚ³£Á¿³Ø¡£
2.¿´Õâ¸öÀý×Ó£¬ÓÃJDK5+junit4.5дµÄÀý×Ó£¬Íêȫͨ¹ý²âÊÔ
Java´úÂë
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import org.junit.Test;
/**
* @author Heis
*
*/
public class StringTest{
@Test
public void testTheSameReference1(){
String str1="abc";
String str2="abc";
String str3="ab"+"c";
String str4=new String(str2);
//str1ºÍstr2ÒýÓÃ×Ô³£Á¿³ØÀïµÄͬһ¸östring¶ÔÏó
assertSame(str1,str2);
//str3ͨ¹ý±àÒëÓÅ»¯£¬Óëstr1ÒýÓÃ×Ôͬһ¸ö¶ÔÏó
assertSame(str1,str3);
//str4ÒòΪÊÇÔÚ¶ÑÖÐÖØзÖÅäµÄÁíÒ»¸ö¶ÔÏó£¬ËùÒÔËüµÄÒýÓÃÓëstr1²»Í¬
asse
Ïà¹ØÎĵµ£º
import java.lang.reflect.Array;
public class ReflectionTest {
public static void main(String[] args) {
try {
Example obj = new Example();
j ......
JavaµÄ»·¾³±äÁ¿ÅäÖãº
(Á½ÖÖ·½·¨ÈÎÑ¡Ò»ÖÖ½Ô¿É)
·½·¨Ò»£º
ÒÀ´Îµã»÷£º“ÎҵĵçÄÔ”£(ÓÒ¼ü)“ÊôÐÔ”£“¸ß¼¶”£“»·¾³±äÁ¿”£¬µ¯³öWindowsµÄ“»·¾³±äÁ¿”ÅäÖÿ¨¡£
Ôړϵͳ±äÁ¿”À¸ÏÂÖ´ÐÐÈýÏî²Ù×÷£º
¢Ùн¨“Classpath”(Èç¹ûÒÑÓУ¬ÔòÖ±½Ó ......
JavaÓïÑԵĹؼü×Ö£¬ÓÃÀ´±íʾһ¸öÓò²»ÊǸöÔÏó´®Ðл¯µÄÒ»²¿·Ö¡£µ±Ò»¸ö¶ÔÏó±»´®Ðл¯µÄʱºò£¬transientÐͱäÁ¿µÄÖµ²»°üÀ¨ÔÚ´®Ðл¯µÄ±íʾÖУ¬È»¶ø·ÇtransientÐ͵ıäÁ¿ÊDZ»°üÀ¨½øÈ¥µÄ
¡¡¡¡Java´úÂë
¡¡¡¡class A implements Serializable {
¡¡¡¡private String name;
¡¡¡¡transient private String address;
¡¡¡¡}
¡¡¡¡ÄÇÃ´Ä ......
ÕâЩ¶¼ÊÇÄúÊé¼ÜÉϱر¸µÄÊéºÍÓ¦¸Ã¾³£Ê¹ÓÃµÄ Web Á´½Ó¡£Ê±¼äÊÇÒ»ÏîÖØÒªµÄ×ÊÔ´£¬±¾ÎÄ°ïÄú»Ø±ÜÄÇЩ·ÖÐĵÄÊÂÇ飬°Ñʱ¼äרעÓÚ×îÓÐÒæÓÚÄú×÷ΪJava ÓïÑÔ³ÌÐòÔ±Ö°ÒµÉúÑĵÄÐÅÏ¢Ô´¡£¾¡¹ÜÓжàÉÙ³ÌÐòÔ±¾ÍÓжàÉÙËûÃÇ×îϲ»¶µÄ²Î¿¼×ÊÁÏ£¬µ«±¾ÎÄÊÕ¼¯µÄÕâЩ¶¼ÊÇÓÅÖÐÑ¡ÓÅ£¬À´Ô´ÓÚÎÒÊé¼ÜÉϵÄ˽¼ÒÕä²ØºÍÐí¶à Java ר¼ÒµÄÍƼö¡£
ÎÒ¿¼ÂÇÁËÁ½ÖÖ×é ......
import java.net.InetAddress;
//±¾³ÌÐòʵÏÖÁË»ñÈ¡±¾µØIPµØÖ·
public class IP {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
InetAddress localHost;
InetAddress []ip;
try{
localHost=InetAddress.getLocalHost();
ip=InetAddr ......