分类为 "转载" 的存档

不写了,气愤!

气死了,刚写的文章没保存,完了!不写了!

2010年5月16日

2009-3-12

There is a good new and a bad new. The good new is that I can move my blog from baidu to cnblog., and the bad one that I must wait. Some days ago, I have the thought of moving my blog. But there is not result because I don’t know how to move. Neither is the blog net doesn’t provide the RSS importing, like CSDN, nor it can only import the home page articles from my baidu blog. At last, I have to seek help from the administrator of the cnblog. Unexpectedly, I actually received the message back. He asked me to transfer the xml file to him. The second day, I got the reply again. He told me that the form of the xml file is not properly and let me wait for a longer time. Thank for the god, thank for him. He must be a good worker, and a good person.

In the next few days, I just wait. And after that I can move my blog to other place.Haha, happy!!

2009年3月12日

反思一下

最近这一个月一直都在学习Struts2,先是从网上下了些资料,文档的,视频的都有,还从图书馆借了本书,结合着学。开始的时候觉得很用,好像是有一个老师在教着一样。struts2的东西学了标签库,国际化,转换器,输入校验。学前面的东西还好点,都能明白,学到转换器部分就有点不理解了,它的反射机制,类型之间怎么这样转换一下就能显示出来,很不理解。就在此卡住了。在网上碰到一个经通struts2的网友,从他那里得知了很多东西。我问他一个问题,他就反问我一个问题。反射机制是什么?泛型了解吗?一问我三不知,所以不得不停下来,再拿起久不看的java再学学了。

今晚去图书馆借了本java的程序设计,明天重新看看了。所以在此申明一下,struts2笔记更新暂停一周。呵呵!

俗话说计划赶不上变化,不过还是要给自己定一个计划。本周后面几天继续JAVA的学习,下周再回过头来学习Struts2。《Thinking in java》这本书我决定先放一放,这本书虽然写得很好,但是我觉得在我没有那么深入了解java的情况下再继续看也是徒劳。好书,要多看几遍!

最近学习了那么久的Struts2,虽然学得很慢,但是还是有很多体会,就是学习一门语言,一定要懂得他的设计思想,懂得他的工作机制,这样学起来就比较轻松了。搞懂思想,多看几遍书!

本来还想写编英文日记的,没时间了,要走了,明天再写了!偷偷懒!哈哈

2008年11月26日

ANT配置

今天学到了怎么使用ANT,为什么要学呢,主要是由于在工程里面,如果有多个java文件要编译,而且这些文件又在不同的包里,一个文件又引用了另一个包的类,这样自己在运行里运行里太麻烦了。那么用ANT可以很方便地解决这个问题。

首先,你所建立的工程要有一个基本的格式,工程里必须包含两个文件夹:src(用来存放java文件),WEB-INF(包含classes和lib文件夹,当然还有一个web.xml文件)。 阅读更多…

2008年10月17日

java中的初始化

1.初始化顺序

在类的内部,变量定义的先后顺序决定了初始化的顺序。即使变量定义散布于方法定义之间,它们仍然会在任何方法(包括构造器)被调用之前得到初始化。下面看个例子就明白了:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Tag{
    Tag(int marker){
        System.out.println("Tag("+marker+")");
    }
}
 
class Card
{
    Tag t1 = new Tag(1);
    Card(){
            System.out.println("Card()");
            t3 = new Tag(33);
    }
    Tag t2 = new Tag(2);
    void f(){
        System.out.println("f()");
    }
    Tag t3 = new Tag(3);
}
 
public class Test
{
    public static void main(String[] args){
        Card t = new Card();
        t.f();
    }
}

执行结果:
Tag(1)
Tag(2)
Tag(3)
Card()
Tag(33)
f()

说明:在main函数中首先创建了一个Card对象,在Card类的定义中有三个变量,分别是t1,t2,t3。虽然它们在类中的定义很分散,但是在对象被创建时,首先要初始化这些对象,所以输出的结果中,先输出Tag(1),Tag(2),Tag(3)。之后才是构造函数,最后才是方法。所以结果很容易理解了。注意此处的t3被初始化了两次。

2.静态数据的初始化

如果是静态数据,情况是相同的。只是有一点,无论创建多少个对象,静态数据都只占用一份存储区域,也就是说只初始化一次。下面看个例子:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
class Bow1
{
    Bow1(int marker){
        System.out.println("Bow1("+marker+")");
    }
    void f(int marker){
        System.out.println("f("+marker+")");
    }
};
 
class Table
{
    static Bow1 b1 = new Bow1(1);
    Table(){
        System.out.println("Talbe()");
        b2.f(1);
    }
    void f2(int marker){
        System.out.println("f1("+marker+")");
    }
    static Bow1 b2 = new Bow1(2);
};
 
class Cupboard
{
    Bow1 b3 = new Bow1(3);
    static Bow1 b4 = new Bow1(4);
    Cupboard(){
        System.out.println("Cupboard");
        b4.f(2);
    }
    void f3(int marker){
        System.out.println("f3("+marker+")");
    }
    static Bow1 b5 = new Bow1(5);
};
 
public class Test1
{
    public static void main(String[] args){
        System.out.println("creating new Cupboard() in main");
        new Cupboard();
        System.out.println("Creating new Cupboard() in main");
        new Cupboard();
        t2.f2(1);
        t3.f3(1);
 
    }
    static Table t2 = new Table();
    static Cupboard t3 = new Cupboard();
};


执行结果有点长,自己执行一下就知道了。还是说明一下吧!

创建Test1类时,首先要为它的变量分配存储空间。而这两个变量又是静态对象,先为t2分配空间,t2是个Table类,而Table类里又有两个静态变量,所以先为这两个变量分配,所以到此执行的结果为:Bow1(1),Bow1(2),Table(),f(1),然后是为t3对象分配空间。最后执行main函数。因为在为t3分配空间时,b3和b4已经初始化过一次了,所以执行new Cupboard()时,就不用再执行static Bow1 b4 = new Bow1(4); 和static Bow1 b5 = new Bow1(5);了。可以自己执行一下试试。


2008年10月15日

Auguest,2008

Yesterday, Huo Ting, my classmate in the university and in the same dorm, came to the library. We haven’t see each other for more than one month. She works at Haier now and is so busy that she must work on the weekend. If I graduate in three years, I don’t find the job that it demands me to work in my rest time.

All the day, I stayed at the library, watching movie and learning. In the afternoon, it began to rain and it became very cool.

2008年8月31日

Auguest 2008

Aug., 29, 2008 Hot

This afternoon went to the library to borrow some books. I was so unlucky that I got a preservative book at the first time and other book can’t remove magnetization. It makes me go up and down.

Tonight, had a bath and felt very comfortable for my clean body. When I washed my clothes, it was close to 8:00. I didn’t want to go to the lab, so I stayed at the dorm and watched the telescript again. I feel that I must write the diary and it’s time for going to bed. Though tomorrow is the weekends, but I don’t want to go out and will go to the lab. Today I borrowed three books about the computer technology, I must study hard..

2008年8月30日

int与integer的区别!

int 是基本类型,直接存数值。
integer是引用数据类型,是对象,用一个引用指向这个对象。

1.Java 中的数据类型分为基本数据类型和引用数据类型
int 是前者>>integer 是后者(也就是一个类)
2.初始化时>>
int i =1;
Integer i= new Integer(1);(要把integer 当做一个类看)

int 是基本数据类型(面向过程留下的痕迹,不过是对java的有益补充)
Integer 是一个类,是int的扩展,定义了很多的转换方法
类似的还有:float Float;double Double;string String等

举个例子:当需要往ArrayList,HashMap中放东西时,像int,double这种内建类型是放不进去的,因为容器都是装object的,这是就需要这些内建类型的外覆类了。
Java中每种内建类型都有相应的外覆类。

下面说一下基本数据类型与对象之间的差别:

基本数据类型的变量与对象之间存在一个很在的差别。当声明一个基本数据类型的变量时,将会分配一个内存空间,并可以立即开始为变量赋值。当声明一个类类型的变量时,只能得到一个存储对象地址的内存空间,但不能直接存储对象本身在。在能够为驍蝗字段赋值,或调用对象的方法之前,必须让变量指向一个现有的对象或新创建的对象。

2008年3月21日