JavaÓïÑÔµÄ26¸öϸ½Ú
JavaÓïÑÔµÄ26¸öϸ½Ú[תÔØ]
Java×÷ΪһÃÅÓÅÐãµÄÃæÏò¶ÔÏóµÄ³ÌÐòÉè¼ÆÓïÑÔ,ÕýÔÚ±»Ô½À´Ô½¶àµÄÈËʹÓᣱ¾ÎÄÊÔͼÁгö×÷ÕßÔÚʵ¼Ê¿ª·¢ÖÐÅöµ½µÄһЩJavaÓïÑÔµÄÈÝÒ×±»È˺öÊÓµÄϸ½Ú,Ï£ÍûÄܸøÕýÔÚѧϰJavaÓïÑÔµÄÈËÓÐËù°ïÖú¡£
1£¬Î»ÒÆÔËËãÔ½½çÔõô´¦Àí
¿¼²ìÏÂÃæµÄ´úÂëÊä³ö½á¹ûÊǶàÉÙ?
int a=5;
System.out.println(a<<33);
°´ÕÕ³£ÀíÍƲâ,°Ña×óÒÆ33λӦ¸Ã½«aµÄËùÓÐÓÐЧλ¶¼ÒƳöÈ¥ÁË£¬ÄÇʣϵĶ¼ÊÇÁã°¡£¬ËùÒÔÊä³ö½á¹ûÓ¦¸ÃÊÇ0²Å¶Ô°¡£¬¿ÉÊÇÖ´Ðкó·¢ÏÖÊä³ö½á¹ûÊÇ10£¬ÎªÊ²Ã´ÄØ£¿ÒòΪJavaÓïÑÔ¶ÔλÒÆÔËËã×÷ÁËÓÅ»¯´¦Àí£¬JavaÓïÑÔ¶Ôa<<bת»¯Îªa<<(b%32)À´´¦Àí£¬ËùÒÔµ±ÒªÒÆλµÄλÊýb³¬¹ý32ʱ£¬Êµ¼ÊÉÏÒÆλµÄλÊýÊÇb%32µÄÖµ£¬ÄÇôÉÏÃæµÄ´úÂëÖÐa<<33Ï൱ÓÚa<<1£¬ËùÒÔÊä³ö½á¹ûÊÇ10¡£
2£¬¿ÉÒÔÈÃi!=iÂð£¿
µ±Äã¿´µ½Õâ¸öÃüÌâµÄʱºòÒ»¶¨»áÒÔΪÎÒ·èÁË£¬»òÕßJavaÓïÑÔ·èÁË¡£Õâ¿´ÆðÀ´ÊǾø¶Ô²»¿ÉÄܵģ¬Ò»¸öÊýÔõô¿ÉÄܲ»µÈÓÚËü×Ô¼ºÄØ£¿»òÐí¾ÍÕæµÄÊÇJavaÓïÑÔ·èÁË£¬²»ÐÅ¿´ÏÂÃæµÄ´úÂëÊä³öʲô£¿
double i=0.0/0.0;
if(i==i){
System.out.println("Yes i==i");
}else{
System.out.println("No i!=i");
}
ÉÏÃæµÄ´úÂëÊä³ö"No i!=i"£¬ÎªÊ²Ã´»áÕâÑùÄØ£¿¹Ø¼üÔÚ0.0/0.0Õâ¸öÖµ£¬ÔÚIEEE 754¸¡µãËãÊõ¹æÔòÀï±£ÁôÁËÒ»¸öÌØÊâµÄÖµÓÃÀ´±íʾһ¸ö²»ÊÇÊý×ÖµÄÊýÁ¿¡£Õâ¸öÖµ¾ÍÊÇNaN("Not a Number"µÄËõд)£¬¶ÔÓÚËùÓÐûÓÐÁ¼ºÃ¶¨ÒåµÄ¸¡µã¼ÆË㶼½«µÃµ½Õâ¸öÖµ£¬±ÈÈ磺0.0/0.0£»ÆäʵÎÒÃÇ»¹¿ÉÒÔÖ±½ÓʹÓÃDouble.NaNÀ´µÃµ½Õâ¸öÖµ¡£ÔÚIEEE 754¹æ·¶ÀïÃæ¹æ¶¨NaN²»µÈÓÚÈκÎÖµ£¬°üÀ¨Ëü×Ô¼º¡£ËùÒÔ¾ÍÓÐÁËi£¡=iµÄ´úÂë¡£
3£¬ÔõÑùµÄequals²Å°²È«£¿
ÎÒÃǶ¼ÖªµÀÔÚJava¹æ·¶ÀﶨÒåÁËequals·½·¨¸²¸ÇµÄ5´óÔÔò£ºreflexive£¨·´ÉíÐÔ£©£¬symmetric£¨¶Ô³ÆÐÔ£©£¬transitive£¨´«µÝÐÔ£©£¬consistent£¨Ò»ÖÂÐÔ£©£¬non-null£¨·Ç¿ÕÐÔ£©¡£ÄÇô¿¼²ìÏÂÃæµÄ´úÂ룺
public class Student{
private String name;
private int age;
public Student(String name,int age){
this.name=name;
this.age=age;
}
public boolean equals(Object obj){
Ïà¹ØÎĵµ£º
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* @author troy(J2EE)
* @version 1.0
*/
public class Test {
public static void main(String[] args) throws Exception {
DateFormat df = DateFormat.getDateInstance();
&n ......
¹ØÓÚ Java Concurrency
×Ô´ÓJavaµ®Éú֮ʱ£¬Java ¾ÍÖ§³Ö²¢ÐеĸÅÄ±ÈÈçÏ̺߳ÍËø»úÖÆ¡£Õâ¸ö½Ì³Ì°ïÖú¿ª·¢¶àÏß³ÌJava³ÌÐòÔ±Äܹ»Àí½âºËÐĵÄJava²¢ÐÐÀíÄîÒÔ¼°ÈçºÎʹÓÃËûÃÇ¡£ ÄÚÈÝÉæ¼°µ½JavaÓïÑÔÖеÄỊ̈߳¬ ÖØÁ·¼¶ÒÔ¼°ÇáÁ¿¼¶Í¬²½»úÖÆ ÒÔ¼°JavaSE 5 ÖеÄËø£¬Ô×ÓÁ¿ ²¢ÐÐÈÝÆ÷£¬Ï̵߳÷¶È ÒÔ¼°Ïß³ÌÖ´ÐÐÕß ......
¹Ø¼ü×Ö: µ×²ãÊý¾Ý Ãû´Ê½âÊÍ£º ²¹Â룺1 ÔÚ¼ÆËã»úϵͳÖУ¬ÊýÖµÒ»ÂÉÓв¹ÂëÀ´±íʾ(´æ´¢). ʹÓò¹Âë,¿ÉÒÔ½«·ûºÅλºÍÆäËûλͳһ´¦Àí;ͬʱ,¼õ·¨Ò²¿É°´¼Ó·¨À´´¦Àí.ÁíÍâ,Á½¸öÓò¹Âë±íʾµÄÊý¾ÝÏà¼Óʱºò,Èç¹û×î¸ßλ(·ûºÅλ)Óнøλ,Ôò½øÎ¥±»ÉáÆú. 2 ²¹ÂëÓëÔÂëµÄת»»¹ý³Ì¼¸ºõÊÇÏàͬµÄ ÊýÖµµÄ²¹Âë±íʾҲ·ÖÁ½ÖÖÇé¿ö£º £¨1£©ÕýÊýµÄ²¹Âë:ÓëÔ ......
eclipseÑ¡Ò»¸ö±äÁ¿ºó£¬Õâ¸öÀàÀïµÄ¸Ã±äÁ¿²»±äÉ«ÎÊÌâ½â¾ö£º
alt + shift + o
/**
* дÈëÈÕÖ¾
* filePath ÈÕÖ¾ÎļþµÄ·¾¶
* code ҪдÈëÈÕÖ¾ÎļþµÄÄÚÈÝ
*/
public
static
boolean
print(String filePath,String code) {
try
{
File tofile
=
new
File(filePath);
......
ѧϰ֮·×ÜÊDz¢²»Æ½Ì¹µÄ£¬Õâ²»£¬Ò»¿ªÊ¼¾ÍÓöµ½ÎÊÌâÁË£ºBad version number in .class file¡£°æ±¾²»¶Ô£¿¿ÉÊÇÎÒÓõÄjavaÒÔ¼°javac¶¼ÊÇJDK5ѽ£¬Ôõô»ØÊ£¿³ýÁ˱àÒë°æ±¾¸úÔËÐа汾²»Ò»ÖÂÍâÊDz»»á³öÏÖÕâÖÖ¿ÉÄܵġ£Í»È»ÏëÆðÇ°¼¸ÌìÊÔÁËÒ»ÏÂJDK6£¬°ÑEclipseµÄJDK±àÒëÆ÷Ñ¡³ÉJDK6ÁË¡£¹ûÈ»£¬½«Æä¸Ä»ØÈ¥JDK5¾ÍÐÐÁË¡£
================== ......