摘要: Explanation: Objects A, B, C are allocated into memory. Then B is unused. The space of B is released. Then D is coming, and is looking for a memory to store. B’s space is released, but is too small to D, so D find another place below C. Later, because of the small space of B left, no variables can u 阅读全文
posted @ 2011-12-02 07:47 allenbackpacker 阅读(111) 评论(0) 推荐(0) 编辑
摘要: Java 只支持单继承,不支持多继承 单继承就是一个类只能有一个父类;多继承就是一个类可以有多个父类。 子类可以继承父类所有的成员变量和成员方法,但子类永远无法继承父类的构造器(Constructor)。在子类构造方法中可以使用语句 Super(参数列表)调用父类的构造方法。 阅读全文
posted @ 2011-12-02 07:46 allenbackpacker 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2011-12-02 07:45 allenbackpacker 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2011-12-02 07:44 allenbackpacker 阅读(351) 评论(0) 推荐(0) 编辑
摘要: when to select “extends”? Is “B” an “A”? If yes, let “B” be the subclass of “A”. B是一个A吗? 如果是,则让B做A的子类。Common mistake: A有一个B吗? 比如:让汽车轮子成为汽车的子类是错误的。因为“汽车轮子”不是一个“汽车”。 阅读全文
posted @ 2011-12-02 07:43 allenbackpacker 阅读(113) 评论(0) 推荐(0) 编辑
摘要: The private properties/methods of the Superclass cannot be accessed by subclass. The non-private properties/methods of the Superclass can be access by subclass’s objects directly.总结: 1. “private” can’t be “extends” 2. “private” 物理上已经被继承过来了,只不过逻辑上不能访问他。所以继承必须慎重,否则浪费内存空间。 阅读全文
posted @ 2011-12-02 07:42 allenbackpacker 阅读(107) 评论(0) 推荐(0) 编辑
摘要: “Extends” simulates the relationship between the things in real world. 父类: Superclass 子类: Subclass A Java superclass is a class which gives a method or methods to a Java subclass. A Java class may be either a subclass, a superclass, both, or neither!———-TestExtends.java———- package ch.allenstudy.new 阅读全文
posted @ 2011-12-02 07:41 allenbackpacker 阅读(165) 评论(0) 推荐(0) 编辑
摘要: How to make sure a class only can generate one object? First, let’s think about this: ———-D.java————- package ch.allenstudy.newway02; public class D { } class A { } class C { public int i = 10; //i 是 C 的属性 } ————————- 这个没有问题吧, i 是 C 的属性。 Let’s add one more line: ———-D.java————- package ch.allenstudy 阅读全文
posted @ 2011-12-02 07:40 allenbackpacker 阅读(110) 评论(0) 推荐(0) 编辑
摘要: For weeks I don’t touch guitar. By accident I know that Hans is the professional of guitar! Amazing! He took the guitar to me for some practice here. The guitar is very good voice. I feel it’s 单板, maybe 红木.Thanks very much, Hans! 阅读全文
posted @ 2011-12-02 07:37 allenbackpacker 阅读(129) 评论(0) 推荐(0) 编辑
摘要: How to know how many objects has been generated for a class? We need use the “static” knowledge. Every time you new an object, you will call the constructor(s) of the class. And the “static” property can be updated every time. So, see below sample: —————————— package ch.allenstudy.newway01; public c 阅读全文
posted @ 2011-12-02 07:28 allenbackpacker 阅读(154) 评论(0) 推荐(0) 编辑
摘要: “this” is only for dynamic method. We don’t need it for static properties/methods, because static properties/methods are already shared in the memory. The reason we use “this” is to distinguish the values for different objects. 阅读全文
posted @ 2011-12-02 07:27 allenbackpacker 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 只有非 private (public, protected, or no identifier) 的 static 成员 (成员指属性和方法)才能通过类名的方式访问。 static 只是表明该成员具有了可以通过类名访问的潜在特征,但是否可以通过类名访问 (class.xxx),还必须具备一个条件:该成员必须是非private Sample: ==================== package ch.allenstudy.newway01;public class Recursion1 { public static void main(String[] args) { System.o 阅读全文
posted @ 2011-12-02 07:26 allenbackpacker 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Sample first:———————————- package ch.allenstudy.newway01; public class TestStatic { public static void main(String[] args) { A aa1 = new A(); A aa2 = new A();aa1.i = 20; //Here, object “aa1″ sets its property i’s value to “20″. aa2.show(); //Here, object “aa2″ call the show() method which calls its 阅读全文
posted @ 2011-12-02 07:24 allenbackpacker 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 静态方法可以直接用类名点出来方法,而普通方法需要创建类的对象后才能调用! 静态的方法和变量会调用时在内存生成一个唯一的标示,你可以理解成在物理内存中给静态一个位子,这样的话在调用的时候可以直接找到,而且会节省内存,但是如果你声明的静态过多的话那么每一个都会在内存有一个位子,那么你就没有资源运行别的,会报内存溢出! 普通方法是由java的gc机制来控制,可能同一个对象或变量在使用的过程中,这个时间的在内存占了一个位子,而上个时间的还没有从内存中删除,这样的话就可能有2个一样的在内存中,这个2个一样东西只是内容值一样,但是内存值不一样,你可以用”==”和”equals”来查看(这个只适用对象和St 阅读全文
posted @ 2011-12-02 07:20 allenbackpacker 阅读(125) 评论(0) 推荐(0) 编辑
摘要: As usual, a sample first. ========================== package ch.allenstudy.newway01;public class ThisPointer {public static void main(String[] args) { A aa1 = new A(10); A aa2 = new A(20); aa1.show(); aa2.show(); }}class A { public int i;public A(int a) { i = a; }public void show() { System.out.prin 阅读全文
posted @ 2011-12-02 07:12 allenbackpacker 阅读(179) 评论(0) 推荐(0) 编辑
摘要: Ctrl+Shift+F to format code in Eclipse 阅读全文
posted @ 2011-12-02 07:11 allenbackpacker 阅读(156) 评论(0) 推荐(0) 编辑
摘要: Let’s write a java file first. File name is Gouzaohanshu.java notice: the main() must be in the class name which is same as the file name, i.e. Gouzaohanshu ============================ package ch.allenstudy.newway01;class Gouzao{ private int i,j; public void set(int a, int b) { i = a; j = b; } publ 阅读全文
posted @ 2011-12-02 07:10 allenbackpacker 阅读(163) 评论(0) 推荐(0) 编辑
摘要: This post is to makde a NullPointerException and explain a little bit. See the capture first.U can see that the value of string[1] is NULL, then the code wants to use charAt() method to call it. Finally there’s a NullPointerException error. This error is always because we want to operate an object w 阅读全文
posted @ 2011-12-01 21:37 allenbackpacker 阅读(305) 评论(0) 推荐(0) 编辑
摘要: This post shows how to create a StackOverflowError with a recursion. Let’s look at the error message first: Exception in thread “main” java.lang.StackOverflowError at ch.allenstudy.newway01.Recursion1.f(Recursion1.java:9) at ch.allenstudy.newway01.Recursion1.g(Recursion1.java:14) at ch.allenstudy.ne 阅读全文
posted @ 2011-12-01 21:35 allenbackpacker 阅读(556) 评论(0) 推荐(0) 编辑
摘要: Recursion: 递归 P(n)= P(n-1)* n 阅读全文
posted @ 2011-12-01 21:34 allenbackpacker 阅读(122) 评论(0) 推荐(0) 编辑
摘要: Private methods/properties (priviate int a;) can’t be accessed from outside of the class. Protected (protected int a;)can be accessed in the class or from its sub-class. Public (public int a;)can be accessed from any places. The methods/properties without any identifier (int a) can be access by the 阅读全文
posted @ 2011-12-01 21:33 allenbackpacker 阅读(144) 评论(0) 推荐(0) 编辑
摘要: Here attached an article about heap (堆) and stack (栈). HeapAndStack Java will store all things into system memory (system memory is physical mem + virtual mem), then it’s the OS to decide they go to physical memory or hard disk (virtual memory) later.堆是先进先出,而栈是先进后出. But in Java, not that obvious dif 阅读全文
posted @ 2011-12-01 08:18 allenbackpacker 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2011-12-01 08:16 allenbackpacker 阅读(155) 评论(0) 推荐(0) 编辑
摘要: Use -7 as sample.int a = -7; //declaration, notice that int is 4 bytes, so 32 bits. The bit representation will be in 2’s complement form.Steps to find 2’s Complement. Take binary representation of positive value (in this case, it is 7) 0000 0000 0000 0000 0000 0000 0000 0111Take 1’s Complement of i 阅读全文
posted @ 2011-12-01 08:12 allenbackpacker 阅读(186) 评论(0) 推荐(0) 编辑
摘要: Question desc: I am using Eclipse for java file. I write below code, and then RUN, but the result is garbage characters. How to fix it? —————————— package ch.allenstudy.newway01; public class TestPrintf { public static void main(String[] args) { // 定义一些变量,用来格式化输出。 double d = 345.678; String s = “Hel 阅读全文
posted @ 2011-12-01 07:51 allenbackpacker 阅读(181) 评论(0) 推荐(0) 编辑
摘要: today, after discuss with Martin, learn with another way. I start to use chinese material, videos and files, and then explain to Martin. See whether this way is faster. ———————- identifier (标识符) start with letter, underline, $ legal: userName, User_Name, _sys_value, $change illegal: 2mail, room#, cl 阅读全文
posted @ 2011-11-25 07:26 allenbackpacker 阅读(340) 评论(0) 推荐(0) 编辑
摘要: Chapter 3: Fundamental Data Types Charpter Goals • To understand integer and floating-point numbers • To recognize the limitations of the numeric types • To become aware of causes for overflow and round off errors • To understand the proper use of constants • To write arithmetic expressions in Java 阅读全文
posted @ 2011-11-25 07:23 allenbackpacker 阅读(107) 评论(0) 推荐(0) 编辑
摘要: While programming, need to become aware of causes for overflow and roundoff errors. Martin mentioned below arithmetic. I think it’s a very good test case for testing in future. 1.2345 * 5.123 / 5.123 = 1.234499999 ? Also, Martin mentioned that before when they paid the goods with tax, sometimes mayb 阅读全文
posted @ 2011-11-25 07:22 allenbackpacker 阅读(121) 评论(0) 推荐(0) 编辑
摘要: An Introduction to Objects and Classes Chapter GoalsTo understand the concepts of classes, objects and methodsTo learn about parameters and return valuesTo understand the purpose and use of constructorsTo be able to browse the API documentation and write documentation commentsTo become familiar with 阅读全文
posted @ 2011-11-25 07:20 allenbackpacker 阅读(102) 评论(0) 推荐(0) 编辑
摘要: Swiss has very different education system. I always think China’s education system has critical issues. Maybe Swiss way is a good refernce for us. There are 3 different ways of education paths. 1. 70% people will do this one: after 9 years of mandatory education, people select to go to some companie 阅读全文
posted @ 2011-11-25 07:19 allenbackpacker 阅读(176) 评论(0) 推荐(0) 编辑
摘要: From Martin, I know more thing about Swiss keyboard. To explain the following, we have to start from the languages using in Swiss. Swiss has several areas – French area, German area, and Italian area. Worb, the place I am working at belongs to German area. So the frist official language is German. . 阅读全文
posted @ 2011-11-25 07:18 allenbackpacker 阅读(251) 评论(0) 推荐(0) 编辑
摘要: Mainly focus on the basic entrance. Introduction, Pseudo Code, Simple java code ======================= Pseudo Code Question: you put $10000 into a bank account that earns 5 % interest per year. How many years does it take for the account balance to be double the original? Start with a year value 0 阅读全文
posted @ 2011-11-25 07:13 allenbackpacker 阅读(217) 评论(0) 推荐(0) 编辑
摘要: This is interesting. The keyboard here is different from what we always use in China. Characters and layout are different.Hans gave me the password to logon the system. There s a “@” character in it. With Chinese keyboard, I will use “Shift 2″ to generateit, but here, u have to use a “Alt Gr” key pl 阅读全文
posted @ 2011-11-25 07:12 allenbackpacker 阅读(445) 评论(0) 推荐(0) 编辑
摘要: http://vontall.blogbus.com/logs/4831888.html昨天把写的那篇《什么时候用GET?什么时候用POST?》给转到了phpx,结果有网友置疑,认为“GET最多不可超过255个字符”。虽说这篇文章是从著名的《PHP & MySQL Web数据库应用开发指南》上摘下来的更让我信任,本着钻研的精神我还是在网上进行了一翻考证。还真找到了最权威的资料:这个是微软官方的解释:http://support.microsoft.com/default.aspx?scid=kb;EN-US;q208427长度是2083字节,路径的最大长度是2048字节, post和g 阅读全文
posted @ 2011-11-24 22:45 allenbackpacker 阅读(1050) 评论(0) 推荐(0) 编辑
摘要: 缺页中断就是要访问的页不在主存,需要操作系统将其调入主存后再进行访问。缺页率:在进行内存访问时,若所访问的页已在主存,则称此次访问成功;若所访问的页不在主存,则称此次访问失败,并产生缺页中断。若程序P在运行过程中访问页面的总次数为S,其中产生缺页中断的访问次数为F,则其缺页率为:F/s.例1. 已知页面走向为1、2、1、3、1、2、4、2、1、3、4,且开始执行时主存中没有页面。若只给该作业分配2个物理块,当采用FIFO页面淘汰算法时缺页率为多少?假定现有一种淘汰算法,该算法淘汰页面的策略为当需要淘汰页面时,就把刚使用过的页面作为淘汰对象,试问就相同的页面走向,缺页率又为多少?解:根据所给页面 阅读全文
posted @ 2011-11-17 13:38 allenbackpacker 阅读(474) 评论(0) 推荐(0) 编辑
摘要: Assume have 2 machines: A and B. The NotepadTest app is in machine B. From machine A, remote desktop machine B, and then: invoke NotepadTest app, click File > Print, then check the items in the printer’s name drop down list. The options in the drop-down list is not of machine B, but of machine A. 阅读全文
posted @ 2011-11-16 13:44 allenbackpacker 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 老徐 says Application Verifier can help to check the memory leak issue of the notepad app. 阅读全文
posted @ 2011-11-16 09:15 allenbackpacker 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 现在浏览器的内核引擎,基本上是四分天下: Trident: IE 以Trident 作为内核引擎; Gecko: Firefox 是基于 Gecko 开发; WebKit: Safari, Google Chrome,搜狗浏览器的高速内核,傲游3 基于 Webkit 开发。 Presto: Opera的内核,但由于市场选择问题,主要应用在手机平台--Opera miniWebKit 的优势在于高效稳定,兼容性好,且源码结构清晰,易于维护。 尽管Webkit内核是个非常好的网页解释机制,但是由于微软把IE捆绑在Windows里,导致许多网站都是按照IE来架设的,很多网站不兼容... 阅读全文
posted @ 2011-10-27 22:28 allenbackpacker 阅读(196) 评论(0) 推荐(1) 编辑
摘要: Alt+Shift+r: rename the method in all the places.Ctrl+Shift+f: layoutCtrl+Shift+o: add the missing packageCtrl+Shift+x > j: run Console Application 阅读全文
posted @ 2011-09-07 20:14 allenbackpacker 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 右键单击 > 属性 > 解除锁定 (Unlock)This is to avoid a Microsoft security defect. 阅读全文
posted @ 2011-09-06 21:38 allenbackpacker 阅读(103) 评论(0) 推荐(0) 编辑