core java(7th edition) 读书笔记

Posted on 2006-07-17 11:11 小猪 阅读(946) 评论(1)  编辑  收藏 所属分类: 读书笔记
 


2006年7月9日 星期日 阴雨
昨天晚上看了前言和第一章.跟很过书一样,主要还是在推销自己的东西啦.
在推销的同时也总体介绍了一下java的一些特性.


2006年7月10日 星期一 阴雨
p15 第3行 java-version 应该改为java -version 书中少了空格.
p25 第7和第8行的命令要注意大小写.
javac ImageViewer.java 中的"I"不能写成i ,V不能写成v .
java ImageViewer 中的"I"不能写成i ,V不能写成v .
否则会出现错误
没注意命令的大小写出现的错误.jpg
改过来以后会显示:
更改命令大小写错误以后的画面.jpg
显示一个窗口程序可以显示gif格式的图片.
结束程序后出现下面的东东:
C:\corejavabook\v1\v1ch2\ImageViewer>
2006年7月13日 星期四 晴
昨天健身腿练得太猛。在床上躺了一天。下楼梯都痛。考试停了一个星期没练就不适应了。哎。
转入正题:p35 中有个例子不是很明白:
"例如,0.125可以表示成Ox1.0p-3.在十六进制表示法中,使用p表示指数,而不是e"
0.125是十进制数的话,它的十六进制数应该是0.2才对啊.p表示以16为底,写成科学记数法应该是
Ox2p-1才对吧?难道是应为Ox1.0p-3中只有后面的-3是十六进制数,1.0是2进制数而且是以2为底?
问题解决:Ox1.0和p后面的-3是用十六进制表示的,底数默认为2.

2006年7月14日 星期五 晴

p42 字条警告处的例子"例如,1<<35与1<<3或8是相同的." 我写了个验证程序,怎么输出结果不同?
public class Test1
{
public static void main(String[] args)
{
int i=1;
int b=0;

b=i<<35;
System.out.println("i<<35"+b);

b=i<<3;
System.out.println("i<<3"+b);

b=i<<8;
System.out.println("i<<8"+b);

b=i<<29;
System.out.println("i<<29"+b);
}
}


输出结果为
i<<358
i<<38
i<<8256
i<<29536870912

解答:
原来是1<<35==1<<3==8的意思。
验证程序应该在输出串后面加个等号

public class Test1
{
public static void main(String[] args)
{
int i=1;
int b=0;

b=i<<35;
System.out.println("i<<35"+b);

b=i<<3;
System.out.println("i<<3="+b);

b=i<<8;
System.out.println("i<<8="+b);

b=i<<29;
System.out.println("i<<29="+b);
}
}

2006年7月16日 星期日 雨
core java p33"注意"字条处:System.out不是有个 print方法么?在apidocument里怎么没看见?
System.out不是有个 print方法么?doc里怎么没看见?.JPG
core java 书上说有的。难道是api版本问题??
there is no print method in api document!.JPG
还真的有...中文api document是不是过时的版本做的?寒
这个问题已经解决.点这里看解答

System.out.print 还确实有!.bmp


2006年7月18日                        星期二                    小雨
关于代码单元和代码点的理解:
1、一个代码点可能包含一个或两个代码单元。
2、在我的测试程序中,“我 ”也只占用一个代码单元。即代码点数等于代码单元数。
下面是在unicode的官方网站上找到的关于unicode的中文,韩文,日文的一些说明:

Q: I have heard that UTF-8 does not support some Japanese characters. Is this correct?

A: There is a lot of misinformation floating around about the support of Chinese, Japanese and Korean (CJK) characters. The Unicode Standard supports all of the CJK characters from JIS X 0208, JIS X 0212, JIS X 0221, or JIS X 0213, for example, and many more. This is true no matter which encoding form of Unicode is used: UTF-8, UTF-16, or UTF-32.

Unicode supports over 70,000 CJK characters right now, and work is underway to encode further additions. The International Standard ISO/IEC 10646 and the Unicode Standard are completely synchronized in repertoire and content. And that means that Unicode has the same repertoire as GB 18030, since that also is synchronized with ISO 10646 — although with a different ordering and byte format.

无论是那个编码方式(UTF-8, UTF-16, or UTF-32)对中文,韩文,日文 支持的字数都一样么?码数好像是不一样吧?.


我的测试程序如下:
public class test0 {
    public static void main(String[] args)
         {String a="我 ";
          int cuCount=a.length();
          System.out.println("the number of code units required for string \"test\" in the UTF-16 encoding is "+cuCount);
          int cpCount=a.codePointCount(0, a.length());
          System.out.println("the number of code points is "+cpCount);
          System.out.println("the end of string \"我 \" is "+a.charAt(a.length()-1));         
         
         }
         
}

输出结果为:
the number of code units required for string "test" in the UTF-16 encoding is 2
the number of code points is 2
the end of string "我 " is [空格]

在eclipse里面找到了set encoding选项,在里面可以设置编码方式。


2006年7月27日       星期四             雨
core java上对int codePointCount(int startIndex,int endIndex)的解释中一个名词没弄明白。
int codePointCount(int startIndex, int endIndex) 5.0

returns the number of code points between startIndex and endIndex - 1. Unpaired surrogates are counted as code points.

中文api对int codePointCount(int startIndex,int endIndex)的解释:
返回此 String 的指定文本范围中的 Unicode 代码点数。文本范围始于指定的 beginIndex,一直到索引 endIndex - 1 处的 char。因此,该文本范围的长度(在 char 中)是 endIndex-beginIndex。该文本范围内未配对的代理项作为一个代码点计数。

MSDN上对Surrogates的解释:
A surrogate pair is a pair of UTF-16 code values that represent a single supplementary character; each of the two code values in the pair is called a surrogate. The first (high) surrogate is a 16-bit code value in the range U+D800 to U+DBFF. The second (low) surrogate is a 16-bit code value in the range U+DC00 to U+DFFF.

原来surrogate 就是unicode-16编码里面的高8位或低8位存储单元。而Unpaired surrogates的意思应该就是指非unicode匹配字符了。而且这些不匹配的字符codePointCount()方法会以8个bit作为计数单元。

Feedback

# re: core java(7th edition) 读书笔记  回复  更多评论   

2006-10-26 22:24 by 木木木
请问这全书的全名?

只有注册用户登录后才能发表评论。


网站导航:
 

posts - 7, comments - 4, trackbacks - 0, articles - 0

Copyright © 小猪