Immutable Strings Objects of the String class are immutable. If you examine the JDK documentation for the String class, you’ll see that every method in the class that appears to modify a String actually creates and returns a brand new String object c…
At the lowest level, data in Java is manipulated using operators Using Java Operators An operator takes one or more argument and produces a new value. The arguements are in a different form than ordinary method calls, but the effect is the same. + :…
---恢复内容开始--- Both C++ and Java are hybird languages. A hybird language allow multiple programming styles The reason C++ is hybird is to support backward compatibility with the C langguage (a superset of the C language) The Java language assumes that…
The genesis of the computer revolution was a machine. The genesis of out programming languages thus tends to look like that machine. 计算机革命起源于机器,因此编程语言的产生也始于对机器的模仿 Computers are mind amplification tools and a different kind of expressive medium. 计算机是大…
Runtime type information (RTTI) allow you to discover and use type information while a program is running This take two forms: 1. "traditional" RTTI, which assumes that you have all the types available at compile time, 2. the reflection mechanis…
The ideal time to catch an error is at compile time, before you even try to run the program. However, not all errors can be detected at compile time. To create a robust system, each component must be robust. By providing a consistent error-reporting…
To solve the general programming problem, you need to create any number of objects, anytime, anywhere. So you can't rely on creating a named reference to hold each one of your objects. Java has several ways to hold objects: 1. the compiler-supported…
The inner class is a valuable feature because it allows you to group classes that logically belong together and to control the visibility of one within the other. However, it's important to understand that inner classes are distinctly different from…
Interfaces and abstract classes provide more structured way to separate interface from implementation. the abstract class, which is a kind of midway step between an ordinary class and an interface. Abstract classes and methods abstract void f(); A cl…
Polymorphism is the third essential feature of an object-oriented programming language,after data abastraction and inheritance. It provides another dimension of separation of interface from implementation, to decouple what from how. Polymorphism allo…
The trick is to use the classes without soiling the existing code. 1. composition--simply create objects of your existing class inside the new class. simply reusing the functionality of the code, not its form 2.inheritance--creates a new class as a t…
Access control ( or implementation hiding) is about "not getting it right the first time." refactoring a primary consideration in object-oriented design is to "separate the thins that change from the thing that stay the same To solve this p…
Two of these safety issues are initialization and cleanup. initialization -> bug cleanup -> running out of resources (most notably, memory) Java adopted the constructor, and in addition has a garbage collector that automoatically releases memory res…
In Java, the keywords include if-else,while,do-while,for,return,break, and a selection statement called switch. Java does not support the much-maligned goto. You can still do a goto-like jump, but it is much more constrained than a typical goto. true…
Learn Java I found out that I and other speakers tended to give the typical audience too many topics too quickly. 我发现我和其他的演讲者往往会在极短的时间内传递太多的主题给听众. I wanted to try to keep everyone up to speed. 我想尽力让每个人都跟上进度 Thinking in Java seminars “Thinking in Java…
容器类库图    List(interface) 次序是List最重要的特点:它保证维护元素特定的顺序.List为Collection添加了许多方法,使得能够向List中间插入与移除元素.(这只推荐LinkedList使用.)一个List可以生成ListIterator,使用它可以从两个方向遍历List,也可以从List中间插入和移除元素. ArrayList* 由数组实现的List.允许对元素进行快速随机访问,但是向List中间插入与移除元素的速度很慢.ListIterator只应该用来由后向…
<Java编程思想第四版完整中文高清版.pdf>-笔记 附录 B 对比 C++和 Java “作为一名 C++程序员,我们早已掌握了面向对象程序设计的基本概念,而且 Java 的语法无疑是非常熟悉的.事实上,Java 本来就是从 C++衍生出来的.” 然而,C++和Java 之间仍存在一些显著的差异.可以这样说,这些差异代表着技术的极大进步.一旦我们弄清楚了这些差异,就会理解为什么说Java 是一种优秀的程序设计语言.本附录将引导大家认识用于区分 Java 和C++的一些重要特征. (1) 最…
在java编程思想第四版中需要使用net.mindview.util包,大家可以直接到http://www.mindviewinc.com/TIJ4/CodeInstructions.html 去下载,并按照所在页面的操作进行操作.当然也可以直接我下载下面的链接,下载的直接是JAR包,可以直接导入并使用: net.mindview.util包:百度网盘:点击下载  密码: ggpi java编程思想第四版源码:百度网盘:点击下载  密码: ur3e 下面我简单的介绍一下源码在Eclipse中的导…
坊间传说这本书翻译得很烂,我倒觉得还好.虽然看原文更准确,但是如果在具备一定编程思维和基础.能够看出来疑问的情况下,还是看中文更快一些,而且这本书本身也不适合初学者看.当然,错误和不通顺还是有的,而且官方和网上居然没有一份公开的勘误表,至少我没有搜到,搜索“Java编程思想第四版勘误”时出现的都是CSDN上的一篇久远的帖子.也许发现问题的人已经懂了,不在意那些错误. 在此记录我发现的问题以及翻译得不够好的地方,如果有人能够看到此文,且发现各种问题,欢迎补充.开源的工具就应当一切周边都开源. 1.…
Java编程思想第四版完整中文高清版.pdf 链接: https://pan.baidu.com/s/1vV5BHF3L-bnaG6WGurdJ_A 提取码: vigy 复制这段内容后打开百度网盘手机App,操作更方便哦…
D.2.1 安插自己的测试代码 插入下述“显式”计时代码,对程序进行评测: long start = System.currentTimeMillis(); // 要计时的运算代码放在这儿 long time = System.currentTimeMillis() - start; 目录 前言 简介 第1章 对象导论 1.1 抽象过程 1.2 每个对象都有一个接口 1.3 每个对象都提供服务 1.4 被隐藏的具体实现 1.5 复用具体实现 1.6 继承 1.6.1 “是一个”(is-a)与“像…
附录 C Java 编程规则 本附录包含了大量有用的建议,帮助大家进行低级程序设计,并提供了代码编写的一般性指导: (1) 类名首字母应该大写.字段.方法以及对象(句柄)的首字母应小写.对于所有标识符,其中包含的所 有单词都应紧靠在一起,而且大写中间单词的首字母.例如: ThisIsAClassName thisIsMethodOrFieldName 若在定义中出现了常数初始化字符,则大写static final基本类型标识符中的所有字母.这样便可标志出它 们属于编译期的常数. Java 包(P…
1. 策略设计模式 参考这篇文章:http://blog.csdn.net/chenjie19891104/article/details/6396458 讲的很清楚,策略设计模式.并且举了一个例子,很具有代表性. 先简单了解一下: 和模板方法模式的区别: 文章里还有一个例子: 备注:我来分解,解释一下这个例子. 将共同的方法定义成了一个接口,在这个接口中并没有这个共同方法的实现. 在Strategy类中,定义了一个方法execute,它的参数是拥有共同方法的接口类. 用户Context在调用S…
欢迎加群:239063848 成团的笔记:该组仅用于技术共享和交流,问题和答案公布 潘基聊天.禁止广告.禁止招聘-- 练习1:(2)创建一个简单的类.第二个类中,将一个引用定义为第一个类的对象.运用惰性初始化来实例化 这个对象. package test; public class Manager { public static void main(String args[]){ Second s=new Second(); s.getFirst(); } /** * 打印结果: */ } cl…
第一题 package net.mindview.holding.test1; import java.util.ArrayList; import java.util.List; /** * 沙鼠 * @author samsung * */ public class Gerbil { static int counter; int gerbilNumber; public Gerbil(){ this.gerbilNumber = counter ++; } public String ho…
第一题 package net.mindview.innerclasses; public class Outer { class Inner { Inner(){ System.out.println("这是一个内部类"); } } public Inner in(){ return new Inner(); } public static void main(String[] args) { Outer out = new Outer(); Outer.Inner inner =…
第三题 package net.mindview.interfaces; abstract class Base{ public Base(){ print(); } abstract void print(); } public class Test3 extends Base{ ; @Override void print() { System.out.println(i); } public static void main(String[] args) { Test3 t = new T…
(略) (略) 创建两个包:debug和debugoff,他们都包含一个相同的类,该类有一个debug()方法,第一个版本显示发送给控制台的String参数,而第二版本什么也不做,使用静态import语句将该类导入到一个测试程序中,并示范条件编译效果. package net.mindview.access; public class Test3 { public static void main(String[] args) { net.mindview.access.debug.Test3…
练习1:创建一个类,它包含一个int域和一个char域,它们都没有被初始化.将他们的值打印出来,以验证Java执行了默认初始化 public class JavaThinking { private static int i; private static char c; public static void main(String[] args){ System.out.println(i); System.out.println(c); //这里char的默认值为'\u0000'可以这样输出…
Thinking in Java 4th 中.英文两版pdf文档,书中源码及课后习题答案.链接:https://pan.baidu.com/s/1BKJdtgJ3s-_rN1OB4rpLTQ 密码:2zc4 http://greggordon.org/java/tij4/solutions.htm 亦为Thinking in Java 4th英文版的课后习题答案. 使用Eclipse运行Thinking in Java 4rd例子源码:https://blog.csdn.net/u0135737…