- 博客(23)
- 资源 (1)
- 收藏
- 关注
原创 Java Puzzlers笔记--puzzle 22:Dupe of URL url的使用
public class BrowserTest{ public static void main(String[] args){ System.out.println("iexplore.exe"); http://www.google.com System.out.println(":maxmize"); }} Solution: 显示:iexplor
2007-03-07 21:57:00
706
原创 Java Puzzlers笔记--puzzle 21: What's my Class, take 2 路径字符问题
package com.javapuzzlers;import java.io.File;public class MeToo{ public static void main(String[] args){ System.out.println(MeToo.class.getName().replaceAll("//.", File.separator) + ".class");
2007-03-07 11:10:00
598
原创 Java Puzzlers笔记--puzzle 20: What's my Class? String.replaceAll()的使用
package com.javapuzzlerspublic class Me{ public static void main(String[] args){ System.out.println(Me.class.getName().replaceAll(".","/") + ".class"); }}Solution: 显示://////
2007-03-07 10:59:00
795
原创 Java Puzzlers笔记--puzzle 19: Classy Fire 注释问题
public class Classifier{ public static void main(String[] args){ System.out.println(classify(n) + classify(+) + classify(2)); } static String classify(char ch){ if("01234567
2007-03-07 10:42:00
901
原创 puzzle 18: String Cheese String的构造
public class StringCheese{ public static void main(String[] args){ byte[] bytes = new byte[256]; for(int i = 0; i bytes[i] = (byte) i; String str = new String(bytes); for(int i = 0; i System.
2007-03-05 23:06:00
636
原创 Java Puzzlers笔记--puzzle 17: Huh? 转义字符问题
Is this a leage Java Program? if so, what does it print?/u0070/u0075/u0062/u006c/u0069/u0063/u0020/u0020/u0020/u0020/u0063/u006c/u0061/u0073/u0073/u0020/u0055/u0067/u006c/u0079/u007b/u0070/u0075/u0062
2007-03-05 22:57:00
674
原创 puzzle 16: Line Printer 转义字符
public class LinePrinter{ public static void main(String[] args){ //Note: /u000A is Unicode representation of linefeed(LF) char c = 0x000A; System.out.println(c); }}Solut
2007-03-05 22:49:00
463
原创 Java Puzzlers笔记--puzzle 15: Hello Whirled -Unicode字符问题
/** * Generated by the IBM IDL-to-Java compiler, version 1.0 * from F:/TestRoot/apps/a1/units/include/PolicyHome.idl * Wednesday, June 17, 1998 6:55:40 oclock AM GMT +00:00 */public class Test{
2007-03-04 12:36:00
561
原创 Java Puzzlers笔记--puzzle 14: Escape Rout (")双引号的问题
public class EscapeRout{ public static void main(String[] args){ // /u0022 is the Unicode escape for double quote("); System.out.println("a/u0022.length() + /u0022b".le
2007-03-04 12:14:00
904
原创 Java Puzzlers笔记--puzzle 13: Animal Farm 优先级以及对象引用问题
public class AnimalFarm{ publi static void main(String[] args){ final String pig = "length: 10"; final Stirng dog = "length: " + pig.length(); System.out.println("Animals are equal: " + pig==dog);
2007-03-04 11:00:00
829
原创 Java Puzzlers笔记--puzzle 12: ABC String与char的区别
public class Abc{ public static void main(String[] args){ String letters = "ABC"; char[] numbers = {"1", "2", "3"}; System.out.println(letters + " easy as " + numbers ); }}Solution:
2007-03-04 10:45:00
900
原创 Java Puzzlers笔记--puzzle 11: The last laugh "" 与''的区别
public class LastLaugh{ public static void main(String[] args){ System.out.println("H" + "a"); System.out.println(H + a); }} Solution:
2007-03-04 10:30:00
517
原创 Java Puzzlers笔记--puzzle 10: Tweedledee += 问题(2)
x = x + i;but this is not:x += i;Solution: Objext x = "Buy "; Stirng i = "Effective java!"; x = x + i;//its legal.显示:But Effective java! x += i; //its illegal.因为+=操作符没有对String类型的定义。TID: The +=
2007-03-03 19:18:00
564
原创 Java Puzzlers笔记--puzzle 9: Tweedledum +=的问题
Provide declarations for the variables x and i such that this is a legal statement: x += i;but this is not: x = x + i;Solution: short x = 0; int i = 123456; x += i; // Contains a hidden cast! x =
2007-03-03 19:17:00
755
原创 Java Puzzlers笔记--puzzle 8: Dos Equis 选择操作符问题
public class DosEquis{ public static void main(String[] args){ char x = X; int i = 0; System.out.println(true ? x : 0); System.out.println(false ? i : x); }}Solution: 显示:X88 ?: 选择操作符的特别的地方
2007-03-03 19:15:00
712
原创 Java Puzzlers笔记--puzzle 7: Swap Meat ^符号问题
public class CleverSwap{ public static void main(String[] args){ int x = 1984; int y = 2001; x ^= y ^=x ^= y; System.out.println("x= " + x + "; y = " + y); }}Solution: 显示:x = 0; y = 1984; 要使用中间变
2007-03-03 19:13:00
464
原创 Java Puzzlers笔记--puzzle 6: Multicast 类型转换
public class Multicast{ public static void main(String[] args){ System.out.println((int)(char)(byte) -1); }Solution: 显示:65535 byte到char的时候出现问题,byte是由符号的,而在char里是没有符号的。}TID: the conversion from b
2007-03-03 19:12:00
536
原创 Java Puzzlers笔记--puzzle 5: The joy of Hex 十六进制计算问题
public class JosOfHex{ public void main(String[] args){ System.out.println( Long.toHexString(0x100000000 + 0xcafebabe)); }}Solution: 显示:cafebabe 由于0x100000000在int中的溢出表示为0x 0000 0001 0000 0000L 而
2007-03-03 19:09:00
615
原创 Puzzle 4: It's Elementary L与1的问题
public class Elementary{ public static void main(String[] args){ System.out.println(12345 + 5432l); }}Solution: 显示:17777 由于5432l中l是L,而不是1TID: Alwasys use a capital el(L) in long literals, neve
2007-03-03 19:03:00
403
原创 Java Puzzlers笔记--Puzzle 3: Long Division 溢出问题
public class LongDivision{ public static void main(String[] args){ final long MICROS_PER_DAY = 24*60*60*1000*1000; final long MILLIS_PER_DAY = 24*60*60*1000; System.out.printl
2007-03-01 13:55:00
647
原创 Java Puzzlers笔记--Puzzle 2: Time for a change 关于浮点型的问题
public class Change{ public static void main(String[] args){ System.out.println(2.00 - 1.10); }} Solution: 结果显示是: 0.8999999999999999999999999999 由于1.1不能用double来准确表示,而是用了一个接近的数来表示
2007-03-01 13:46:00
490
原创 Java Puzzlers笔记--Puzzle 1: Oddity奇偶问题
public static boolean isOdd(int i){ return i%2 == 1;} Solution: 以上程序只有3/4的数正确,因为当i是负数时,不管是奇数还是偶数都会返回false;java puzzlers 上的提示: test that your methods behave properly when passed negative, zero
2007-03-01 13:28:00
473
原创 java 6的认识
刚刚看完csdn上的文章介绍java虚拟机,觉得讲到java 6的一点新功能,我们必须知道的,要不我们就out了...文章是一篇Danny Coward访问;英文的原连接 http://www.artima.com/lejava/articles/dynamic_languages.html我把一些重要的地方截下来:Java SE 6 is no longer only about t
2007-02-28 21:47:00
489
Win7-USB3.0-Creator-V3-Win7Admin
2018-01-30
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅