JavaÖеÄÀàÐÍת»»
±¾×÷Æ·²ÉÓÃ֪ʶ¹²ÏíÊðÃû-·ÇÉÌÒµÐÔʹÓÃ-Ïàͬ·½Ê½¹²Ïí 2.5 Öйú´ó½Ðí¿ÉÐÒé½øÐÐÐí¿É¡£
ÎÞÂÛÔÚC/C++»¹ÊÇÔÚJava£¬Ç¿ÖÆÀàÐÍת»»ÒѾ²»ÊÇİÉúµÄ¸ÅÄîÁË¡£µ«ÊÇÒªÏëÈ«ÃæÕÆÎÕJavaÖÐÀàÐÍת»»µÄÒªµã¿É²»ÄÇô¼òµ¥£¬±¾ÎĽ«´øÁì´ó¼ÒһͬÁ˽âÓйØJavaÀàÐÍת»»µÄËùÓÐÒªµã¡£
ÊýÖµÀàÐ͵ÄÀàÐÍת»»
ÖÚËùÖÜÖª£¬JavaÓÐÁ½ÖÖÊý¾ÝÀàÐÍ£º»ù±¾Êý¾ÝÀàÐÍÓëÒýÓÃÊý¾ÝÀàÐÍ£»JavaÓÖÓÐÁ½ÖÖ»ù±¾µÄÀàÐÍת»»ÔÔò£ºÍØ¿íת»»ÔÔò£¨widening conversion£©ÓëËõСת»»ÔÔò£¨narrowing conversion£©¡£
ÍØ¿íת»»ÓëËõСת»»Ö»ÊÊÓÃÓÚ»ù±¾Êý¾ÝÀàÐÍÖеÄÊýÖµÀàÐÍ¡£Êý¾ÝÖµÀàÐͰ´ÕÕ·¶Î§´ÓСµ½´óÅÅÁÐΪ£º
byte short int long float double
µ±Ä¿±êÀàÐ͵ķ¶Î§±ÈÔ´ÀàÐ͵ķ¶Î§´óʱ×ñÑÍØ¿íת»»ÔÔò£¬²»±ØÇ¿ÖÆ×ª»»¡£È磺
byte b = 10;
short s = b;
·´Ö®Ôò×ñÑËõСת»»ÔÔò£¬¼´
µ±Ä¿±êÀàÐ͵ķ¶Î§±ÈÔ´ÀàÐ͵ķ¶Î§Ð¡Ê±×ñÑËõСת»»ÔÔò£¬±ØÐëÇ¿ÖÆ×ª»»¡£È磺
short s = 10;
byte b = (byte)s;
ÐèҪעÒâµÄÊÇÍØ¿íת»»ÔÔò²»¶ªÊ§Êý¾Ý¡£È磺
long l1 = Long.MAX_VALUE;
float f = l1;
long l2 = (long)f;
System.out.println("ת»»Ç°£º" + l1);
System.out.println("ת»»ºó£º" + l2);
ÉÏÀýÊä³ö½á¹ûΪ£º
ת»»Ç°£º9223372036854775807
ת»»ºó£º9223372036854775807
ËõСת»»ÔÔòÔÚ³¬³öÄ¿±êÀàÐ͵Äȡֵ·¶Î§Ê±»áµ¼ÖÂÊý¾Ý¶ªÊ§¡£È磺
int i1 = 257;
byte b = (byte)i1;
int i2 = b;
System.out.println("ת»»Ç°£º" + i1);
System.out.println("ת»»ºó£º" + i2);
ÉÏÀýÊä³ö½á¹ûΪ£º
ת»»Ç°£º257
ת»»ºó£º1
×Ö·ûÀàÐÍÓëÊýÖµÀàÐÍÖ®¼äµÄת»»
»ù±¾Êý¾ÝÀàÐÍcharµÈͬÓÚÒ»¸öÎÞ·ûºÅ¶ÌÕûÐÍ£¬·¶Î§´Ó0x0000µ½0xFFFF¡£
´ÓÆäËüÊýÖµÀàÐÍת»»µ½charÀàÐÍʱ£¬±ØÐë½øÐÐÇ¿ÖÆ×ª»»¡£È磺
byte b = 10;
short s = 10;
int i = 10;
long l = 10L;
float f = 10.0F;
double d = 10.0;
char c = (char)b;
c = (char)s;
c = (char)i;
c = (char)l;
c = (char)f;
c = (char)d;
½«charÀàÐÍת»»³ÉÆäËüÊýÖµÀàÐÍʱ£¬³ýbyte¡¢short±ØÐëÇ¿ÖÆ×ª»»Í⣬int long float double¾ù²»±ØÇ¿ÖÆ×ª»»¡£È磺
char c = 'a';
byte b = (byte)c;
short s = (byte)c;
int i = c;
long l = c;
float f = c;
double d = c;
ÒýÓÃÀàÐ͵ÄÀàÐÍת»»
ÒýÓÃÀàÐ͵ĸ³Öµ³£¼ûÓÚ¾ßÓм̳йØÏµµÄÁ½ÖÖÀàÐ͵Äת»»¡£ÈçÏÂÃæµÄÀý×Ó£º
public class Person {
p
Ïà¹ØÎĵµ£º
ÀàµÄ³õʼ»¯ºÍ¶ÔÏó³õʼ»¯ÊÇ JVM ¹ÜÀíµÄÀàÐÍÉúÃüÖÜÆÚÖзdz£ÖØÒªµÄÁ½¸ö»·½Ú£¬Google ÁËÒ»±éÍøÂ磬ÓйØÀà×°ÔØ»úÖÆµÄÎÄÕµ¹ÊDz»ÉÙ£¬È»¶øÀà³õʼ»¯ºÍ¶ÔÏó³õʼ»¯µÄÎÄÕ²¢²»¶à£¬ÌرðÊÇ´Ó×Ö½ÚÂëºÍ JVM ²ã´ÎÀ´·ÖÎöµÄÎÄÕ¸üÊÇÏÊÓÐËù¼û¡£
±¾ÎÄÖ÷Òª¶ÔÀàºÍ¶ÔÏó³õʼ»¯È«¹ý³Ì½øÐзÖÎö£¬Í¨¹ýÒ»¸öʵ¼ÊÎÊÌâÒýÈ룬½«Ô´´úÂëת»»³É JVM ×Ö½ÚÂëºó£¬ ......
1.ÉùÃ÷Êý×éÒýÓñäÁ¿Ê±²»ÄÜÖ¸¶¨Êý×éµÄ³¤¶È¡£È磺int x[1];Õâ¾ä»°·Ç·¨¡£
2.Êý×é¶ÔÏóµÄ´´½¨£¬ÀýÈ磺
int [] scores = new int[100];
Ê×ÏÈÔÚ¶ÑÖзÖÅäÄÚ´æ¿Õ¼ä£¬ÉÏÊöµÄ¾ÍÊÇ400¸ö×Ö½Ú£¬È»ºó¾Í¸øÆä¸³Ä¬ÈÏÖµ£¬¸÷¸öÊý¾ÝÀàÐ͵ÄĬÈÏÖµ²»Í¬£¬intΪ0.
3.·µ»ØÊý×é¶ÔÏóµÄÒýÓãº
int [] x =new int [10]; <=> int size = 10; i ......
Java ʵÓþÑé×ܽá --Swing ƪ
ǰÑÔ
±¾ÎÄǰÑÔ²¿·ÖΪÎÒµÄһЩ¸ÐÏ룬Èç¹ûÄãÖ»¶Ô±¾ÎĽéÉÜµÄ Java ʵÓü¼ÇɸÐÐËȤ£¬¿ÉÒÔÌø¹ýǰÑÔÖ±½Ó¿´ÕýÎĵÄÄÚÈÝ¡£
±¾ÎĵÄд×÷¶¯»úÀ´Ô´ÓÚ×î½ü½Ó¸øÈ˼ҰïæдµÄÒ»¸öС³ÌÐò£¬Ö÷ÒªÓÃÓÚ¹ÜÀí·ÖÆÚ¸¶¿îµÄ»õ¿îµÄһϵÁйÜÀí£¬°üÀ¨¹ýÆÚ¿îµÄ¼Í¼£¬¹ýÆÚ¿îÀûÏ¢µÄ¼ÆË㣬ΪÌáǰ¸¶¿îµÄÓû§ÌṩһЩ·µ¿î½ ......
package test;
import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
public class XmlTest {
public static void main(String[] args) {
File xmlFile=new File("test/xml.xml");
DocumentBuilderFactory documentBuilderFactor ......