博文

目前显示的是 五月, 2009的博文

Java string immutability

The theory of the immutability of the String class says that once created, a string can never be changed. Real life experience with Java programming implies that this is not true. Take the following code EX1: public class ImString{ public static void main(String argv[]){ String s1 = new String("Hello"); String s2 = new String("There"); System.out.println(s1); s1=s2; System.out.println(s1); } } If Strings cannot be changed then s1 should still print out Hello, but if you try this snippet you will find that the second output is the string "There". What gives? The immutability really refers to what the String reference points to. When s2 is assigned to s1 in the example, the String containing "Hello" in the String pool is no longer referenced and s1 now points to the same string as s2 . The fact that the "Hello" string has not actually been modified ...

JAVA object serialization

two articals : http://java.sun.com/developer/technicalArticles/Programming/serialization/ http://www.acm.org/crossroads/xrds4-2/serial.html my first glance about object serialization : Java provide object serialization to allow save or retrive data in a way of object. A so-called serialized object is an object reperesented as a sequence of bytes that include both information about the data and the type of those data and the object. Before an object of a class can be serialized, the class must implement the interface "Serializable". In a class that implements "Serializable", programmer must be sure every instance variable that is a serializable type. Any instance variable that is not serializable must be declared "transient" to indicate that it is not serializable and should be ignored during the serialization process. Array object are serializable, however, if the array contains references to other objects that is not serializable, those obj...

Setup cvs

图片
相信有过团队开发经历的人,都用过这样或者那样的版本控制系统。比如,我们就使用CVS(并发版本系统)来管理源代码。它的好处,对于用过的人自然不用多说。 而以前对于CVS的使用也仅限于工作的需要,对于自己的文件和源代码并没有涉及使用, 为此也吃过一些苦头,比如轻易删除的一段代码又要费劲的重写出来。为了避免悲剧重演,我给自己搭建了一套CVS,然后将自己还在更新的文件和源代码放入统 一的目录中打上了CVS的标记。这样只要每天提交更新不误,就不会再出现删除后的抓狂了…… 既然CVS这么有用,你也来为自己的资料加道保险吧。 CVS服务器我们选择开源的CVSNT,可以从 http://www.cvsnt.org/ 得到。由于个人使用的工作环境一般为Windows,所以我们主要演示Windows平台下的安装配置。对应Windows平台下载得到的是一个安装文件,安装过程没有什么好说的,重启机器后CVSNT就安装完毕了。 CVSNT会在你的机器中启动两个服务: 当然现在的CVSNT还不能使用,你还要给CVSNT指定数据仓库的位置。在你准备存放版本控制信息 的目录下,添加作为数据仓库的文件夹,比如我在d盘下创建srcBase作为数据仓库。在“开始”菜单里选择CVSNT的子选项“CVSNT Control Panel”。在弹出的窗口中,选择“Repository configuration”Tab窗口: 点击Add按钮,在弹出窗口中,指定好你将作为数据仓库的位置,点击确定完成操作。这样就可以使用CVSNT服务器了。 另外在第三个Tab窗口“Server settings”中,可以设定使用者的身份、访问端口、temp目录和加密等属性。其中temp目录默认在C盘,你可以指定到其它的地方。 对于CVS的更多设置,比如远程用户的访问(这是团队开发不可少的配置,而本文假设服务器和客户端存在于一台机器),可以参见安装目录下的帮助文档,或者在链接 http://cvsdoc-zh.gro.clinux.org/cvsdoc/zh_CN/html/1_12_13/index.html#toc_Top 中得到中文手册。 现在你就可以通过命...

iTrainer project

project website: http://web.student.chalmers.se/groups/idp09-3/ youtube: http://www.youtube.com/watch?v=huqsFSLfXZk or search for itrainer exhibition website: http://www.ide09.se/