Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java ´íÎó´úÂëÌáʾ

 //=============================Êä³öÆæÊý
public class OddTest {
public static boolean isOdd(int i){
return i % 2 != 0; //±È½Ï i % 2 == 0;×¢£º -1%2 = -1
}
public static void main(String[] args) {
for(int i = -10; i <= 10; i++) {
System.out.println(isOdd(i));
}
}
}
//=============================¸¡µãÊýÏà¼õ
import java.math.BigDecimal;
public class DoubleMinus {
public static void main(String[] args) {
System.out.println(new BigDecimal("2.0").subtract(new BigDecimal("1.1")));
System.out.printf("%.1f", 2.0-1.1);//±È½Ï System.out.println(2.0 - 1.1) = 0.8999999999999999
}
}
Ϊʲô¸¡µãÊý»á¶ªÊ§¾«¶È£¿
Ê®½øÖÆÊýµÄ¶þ½øÖƱíʾ¿ÉÄܲ»¹»¾«È·
¸¡µãÊý»òÊÇË«¾«¶È¸¡µãÊýÎÞ·¨¾«È·±íʾµÄÇé¿ö²¢²»ÉÙ¼û¡£¸¡µãÊýֵû°ì·¨ÓÃÊ®½øÖÆÀ´¾«È·±íʾµÄÔ­ÒòÒª¹é¾ÌÓÚCPU±íʾ¸¡µãÊýµÄ·½·¨¡£ÕâÑùµÄ»°Äú¾Í¿ÉÄÜ»áÎþÉüһЩ¾«¶È£¬ÓÐЩ¸¡µãÊýÔËËãÒ²»áÒýÈëÎó²î¡£ÒÔÉÏÃæÌáµ½µÄÇé¿öΪÀý£¬2.4µÄ¶þ½øÖƱíʾ²¢·Ç¾ÍÊǾ«È·µÄ2.4¡£·´¶ø×îΪ½Ó½üµÄ¶þ½øÖƱíʾÊÇ 2.3999999999999999¡£Ô­ÒòÔÚÓÚ¸¡µãÊýÓÉÁ½²¿·Ö×é³É£ºÖ¸ÊýºÍβÊý¡£¸¡µãÊýµÄֵʵ¼ÊÉÏÊÇÓÉÒ»¸öÌض¨µÄÊýѧ¹«Ê½¼ÆËãµÃµ½µÄ¡£ÄúËùÓöµ½µÄ¾«¶ÈËðʧ»áÔÚÈκβÙ×÷ϵͳºÍ±à³Ì»·¾³ÖÐÓöµ½¡£
×¢Ò⣺ Äú¿ÉÒÔʹÓÃBinary Coded Decimal (BCD)¿âÀ´±£³Ö¾«¶È¡£BCDÊý×Ö±àÂë·½·¨»á°Ñÿһ¸öÊ®½øÖÆÊý×Öλµ¥¶À±àÂë¡£
ÀàÐÍʧÅä
Äú¿ÉÄÜ»ìºÏÁ˸¡µãÊýºÍË«¾«¶È¸¡µãÊýÀàÐÍ¡£ÇëÈ·¶¨ÄúÔÚ½øÐÐÊýѧÔËËãµÄʱºòËùÓеÄÊý¾ÝÀàÐÍÈ«²¿Ïàͬ¡£
×¢Ò⣺floatÀàÐ͵ıäÁ¿Ö»ÓÐ7λµÄ¾«¶È£¬¶ødoubleÀàÐ͵ıäÁ¿ÓÐ15λµÄ¾«¶È¡£
ÈçºÎ½øÐи¡µãÊý¾«¶È¼ÆË㣿
JavaÖеļòµ¥¸¡µãÊýÀàÐÍfloatºÍdouble²»Äܹ»½øÐÐÔËËã¡£²»¹âÊÇJava£¬ÔÚÆäËüºÜ¶à±à³ÌÓïÑÔÖÐÒ²ÓÐÕâÑùµÄÎÊÌâ¡£ÔÚ´ó¶àÊýÇé¿öÏ£¬¼ÆËãµÄ½á¹ûÊÇ׼ȷµÄ£¬µ«ÊǶàÊÔ¼¸´Î£¨¿ÉÒÔ×öÒ»¸öÑ­»·£©¾Í¿ÉÒÔÊÔ³öÀàËÆÉÏÃæµÄ´íÎó¡£ÏÖÔÚÖÕÓÚÀí½âΪʲôҪÓÐBCDÂëÁË¡£
Õâ¸öÎÊÌâÏ൱ÑÏÖØ£¬Èç¹ûÄãÓÐ9.999999999999Ôª£¬ÄãµÄ¼ÆËã»úÊDz»»áÈÏΪÄã¿ÉÒÔ¹ºÂò10ÔªµÄÉÌÆ·µÄ¡£
ÔÚÓеıà³ÌÓïÑÔÖÐÌṩÁËרÃŵĻõ±ÒÀàÐÍÀ´´¦ÀíÕâÖÖÇé¿ö£¬µ«ÊÇJavaûÓС£ÏÖÔÚÈÃÎÒÃÇ¿´¿´ÈçºÎ½â¾öÕâ¸öÎÊÌâ¡£

ËÄÉáÎåÈë
ÎÒÃǵĵÚÒ»¸ö·´Ó¦ÊÇ×öËÄÉáÎåÈë¡£MathÀàÖеÄround·½·¨²»ÄÜÉèÖñ£Áô¼¸Î»Ð¡Êý£¬ÎÒÃÇÖ»ÄÜÏóÕâÑù£¨±£ÁôÁ½Î»£©£º
public double round(double value){


Ïà¹ØÎĵµ£º

JAVA ¶¯Ì¬¹¹½¨Ê÷

1.       ¶Ô×Ô¼ºµÄ×ܽáºÍÀí½âµÄÉý»ªÊÇÎÒϲ»¶×öµÄÒ»¼þÊ£¬ÔÚʵ¼ÊÏîÄ¿¹ý³ÌÖУ¬ºÜ¶àµØ·½¶¼Óõ½¶¯Ì¬Éú³ÉÊ÷Ðβ˵¥µÄµØ·½£¬ÏÖÔھ͸ø´ó¼Ò½²½²ÈçºÎ¶¯Ì¬Éú³ÉÒ»¿ÃÊ÷¡£
2.       Ê×ÏÈÎÒÃDZØÐëÒª½¨Á¢Ê÷µÄ½ÚµãÄ£ÐÍ£¬ÆäʵÊ÷µÄ½ÚµãÄ£ÐÍÖÐÍùÍù¾ÍÊÇÎÒÃÇÐèÒª´æ·ÅµÄÊý¾Ý¶ÔÏó£¬ºÜ ......

JAVAѧϰ֮·£º²»×ßÍä·£¬¾ÍÊǽݾ¶(¶þ)

±¸×¢£º
±¾ÎÄÑ¡×ÔChinaITLabÍøУ¿Î³Ì¡¶ÁõÏþÌÎJava¾Íҵֱͨ°àV2.0¡·Ö®Ô¤±¸ÖªÊ¶£¬µã»÷ÕâÀïÁ˽â¸ü¶à£¡
JAVAѧϰ֮·---ѧϰ·Ïß¼°Òªµã
2£®Èí¼þ¿ª·¢Ñ§Ï°Â·Ïß
Á½Ç§¶àÄêµÄÈå¼Ò˼Ïë¿×ÃÏÖ®µÀ£¬ÖÐÓ¹µÄ˼Ïë͸Èë¹ÇË裬¼È²»Ã°½øÒ²²»±£Êز¢·ÇÖÐÓ¹Ö®µÀ£¬¶øÊÇÕÒѰѧϰÈí¼þ¿ª·¢µÄÕýȷ·ÏßÓë¹æÂÉ¡£
´ÓÈí¼þ¿ª·¢ÈËÔ±µÄÉúÑĹ滮À´½²£¬ÎÒÃÇ¿É ......

java homework

ʹÓÃjava.lang.MathÀ࣬Éú³É500¸ö0~99µÄËæ»úÊý£¬½øÐÐÅÅÐòÊä³ö£¬²¢Çó×î´óÖµ¡¢×îСֵ¡¢Æ½¾ùÖµ¡¢±ê×¼²î¡¢·½²î¡¢¾ù·½²î£»
import java.lang.Math;
import java.util.Arrays;
public class Main {
public static void main(String args[]) {
//create random
int [] data =new int[500];
double sum = 0, avg =0; ......

java³ÌÐòÐÔÄÜ

JavaʹµÃ¸´ÔÓÓ¦ÓõĿª·¢±äµÃÏà¶Ô¼òµ¥£¬ºÁÎÞÒÉÎÊ£¬ËüµÄÕâÖÖÒ×ÓÃÐÔ¶ÔJavaµÄ´ó·¶Î§Á÷Ðй¦²»¿Éû¡£È»¶ø£¬ÕâÖÖÒ×ÓÃÐÔʵ¼ÊÉÏÊÇÒ»°ÑË«Èн£¡£Ò»¸öÉè¼ÆÁ¼ºÃµÄJava³ÌÐò£¬ÐÔÄܱíÏÖÍùÍù²»ÈçÒ»¸öͬÑùÉè¼ÆÁ¼ºÃµÄC++³ÌÐò¡£ÔÚJava³ÌÐòÖУ¬ÐÔÄÜÎÊÌâµÄ´ó²¿·ÖÔ­Òò²¢²»ÔÚÓÚJavaÓïÑÔ£¬¶øÊÇÔÚÓÚ³ÌÐò±¾Éí¡£Ñø³ÉºÃµÄ´úÂë±àдϰ¹ß·Ç³£ÖØÒª£¬±ÈÈçÕýÈ·µ ......

[ת]Does Java pass by reference or pass by value?

http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html
Does Java pass by reference or pass by value?
Why can't you swap in Java?
By Tony
Sintes, JavaWorld.com, 05/26/00

Print
Email
Feedback
Resources
Discuss
(76)
Digg
Reddit
SlashDot
Stumble
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ