我在学校的时候就没有认真学习过Java,在开始学android的时候,也没有时间及时补上,现在有点时间,就觉得自己的基础太差了,所以开始把Thinking java的电子书拿出来读一读。因为英语不好,所以读得很慢。我读的是英文版的。我觉得不要因为自己的英语不好,就老读中文版的,其实先进IT技术都是从国外先发明的,所以你想要领略地道的东西还是读读英文的好。
我决定把在读的过程中觉得需要记住的地方摘录下来,方便以后复习。嘿嘿!
1,
Everything is an object.
2,
Manipulate objects with references
3,
Each object keeps its own storage for its fields; the fields are not shared among objects.
4,
Scope of objects
Java objects do not have the same lifetimes as primitives. When you
create a Java object using new, it hangs around past the end of the scope.
Thus if you use:
{
String s = new String("a string");
} // End of scope
the reference s vanishes at the end of the scope. However, the String
object that s was pointing to is still occupying memory. In this bit of code, there is no way to access the object because the only reference to it is out of scope.
5,
Default values for primitive members
Note carefully that the default values are what Java guarantees when the variable is used as a member of a class. This ensures that member
variables of primitive types will always be initialized (something C++
doesn’t do), reducing a source of bugs. However, this initial value may not be correct or even legal for the program you are writing. It’s best to always explicitly initialize your variables.
This guarantee doesn’t apply to “local” variables—those that are not fields of a class. Thus, if within a method definition you have:
int x;
Then x will get some arbitrary value (as in C and C++); it will not
automatically be initialized to zero.
6,
Return keyword
You can also see the use of the return keyword, which does two things.
First, it means “leave the method, I’m done.” Second, if the method
produces a value, that value is placed right after the return statement.
7,
Name visibility
A problem in any programming language is the control of names.how do you distinguish one name from another and prevent the two names from “clashing?” To solve this problem, C++ introduced
namespaces using additional keywords In fact, the Java creators want you to use your Internet domain name in reverse since those are guaranteed to be unique.
After your reversed domain name, the dots are intended to represent subdirectories
so now the entire package name is lowercase.
8,
Using other components
This is accomplished by telling the Java compiler exactly what classes you want
using the import keyword. import tells the compiler to bring in a
package, which is a library of classes. (In other languages, a library could
Chapter 2: Everything is an Object 101
consist of functions and data as well as classes, but remember that all
code in Java must be written inside a class.)
9,
The static keyword
One is if you want to have only one piece of storage for a particular piece of data, regardless of how many objects are created, or even if no objects are created. The other is if you need a method that isn’t associated with any particular object of this class. That is, you need a method that you can call even if no objects are created. You can achieve both of these effects with
the static keyword. When you say something is static, it means that data or method is not tied to any particular object instance of that class. So even if you’ve never created an object of that class you can call a static method or access a piece of static data. With ordinary, non-static data and methods you must create an object and use that object to access the data or method, since non-static data and methods must know the particular object they are working with. Of course, since static methods don’t need any objects to be created before they are used, they cannot directly access non-static members or methods by simply calling those other members without referring to a named object (since non-static members and methods must be tied to a particular object).
10,The name of the class is the same as the name of the file. When you’re creating a stand-alone program such as this one, one of the classes in the file must have the same name as the file. (The compiler complains if you don’t do this.)
分享到:
相关推荐
### Thinking in Java 读书笔记知识点总结 #### 一、万事万物皆对象 1. **对象存储位置** - **寄存器**:程序无法直接控制。 - **栈(Stack)**:存储基本类型数据和对象引用,但对象本身不在此处。 - **堆(Heap)...
### Thinking in Java 自学笔记——第二章 一切皆对象 #### 重要概念解析 ##### 2.1 用引用操纵对象 在Java中,一切都被视为对象,这意味着无论是字符串、数字还是其他数据类型都可以被视为对象来进行操作。当...
Thinking in Java 自学笔记——第一章 对象导论 本章节总结了面向对象程序设计(Object-oriented Programming, OOP)的基本概念和原则,以帮助读者更好地理解 Java 编程语言。以下是对标题、描述、标签和部分内容的...
《Thinking in Java》是一本深度解析Java编程语言的经典著作,其深入浅出的讲解和丰富的实例使得读者能够全面理解Java的精髓。以下是对书中部分关键知识点的总结: 1. **Java 泛型**:泛型是Java SE 5.0引入的重要...
《王者归来之Thinking in Java读书笔记》是对Bruce Eckel的经典之作《Thinking in Java》第四版的深度学习与总结。这本书是Java程序员的必备参考书,它深入浅出地阐述了Java语言的核心概念和技术,旨在帮助读者理解...
在IT领域,特别是Java编程的学习过程中,"JAVA夜未眠,thinkingJAVA和学习笔记"这一主题涵盖了许多核心概念和实践技巧。以下是对这些资源的详细解释: 首先,"Java夜未眠"可能指的是一个深入探讨Java编程的书籍或...
### Thinking In Java的第一章知识点概览 #### 一、面向对象的基本概念 在《Thinking In Java》这本书的第一章中,作者介绍了Java的核心理念——一切皆对象。Java采用了一种统一的语法来处理所有事物,这是因为Java...
### Thinking in Java 读书笔记知识点总结 #### 一、构造器与方法重载 1. **构造器的特点**: - 构造器不返回任何值,与返回`void`不同。 - 当未在类中声明构造器时,编译器会自动生成一个默认的无参构造器。 - ...
### Thinking In Java 学习笔记知识点总结 #### 面向对象编程(OOP)的重要性及其影响 面向对象编程(OOP)在软件开发领域产生了深远的影响。它不仅提高了开发效率和降低了维护成本,还简化了设计流程,使得编程任务...
《Thinking in Java》是Bruce ...以上只是《Thinking in Java》第五部分可能涵盖的部分内容,实际笔记可能还涉及其他高级主题,如反射、注解、并发编程等。通过深入学习这些知识,可以全面提升对Java的理解和应用能力。
读书笔记:Thinking in Java (Java 编程思想)
这些只是《Thinking in Java》中的一部分内容,全书还包括类、接口、多态性、异常处理、集合框架、并发编程等多个主题,是Java学习者的宝贵资源。理解和掌握这些基础知识是成为一名熟练Java程序员的关键步骤。
我的学习笔记的书本课程来自于:《Thinking in Java》和《Head First Java》 视频课程主要来自于:廖雪峰老师《Java 基础课程》 如涉及版权侵犯请联系我更正。 初来乍到,文笔稚嫩,学识浅薄,请多指教。
`final` 关键字是 Java 中的一个保留字,用于修饰变量、方法和类。`final` 关键字的使用有以下几点: 1. 当一个变量被声明为 `final` 时,该变量的值不能被改变。 2. 当一个方法被声明为 `final` 时,该方法不能被...
《Thinking in Java》是 Bruce Eckel 编著的一本经典Java编程教材,它以其深入浅出的讲解方式和丰富的实例闻名于世。这本书涵盖了Java语言的基础到高级特性,包括面向对象编程、集合框架、多线程、网络编程、异常...
这是我从一位认识的大神那里要来的第一手资料,主要是他对Java面向对象的一些认识,我看了之后顿时犹如醍醐灌顶,对面向对象的思想有了深刻认识!原来以前只是学了皮毛而已。遗憾的是,这个笔记他没有写完,我只是看...
"Thinking in Java"是一本由Bruce Eckel编写的经典书籍,它深入浅出地介绍了Java编程语言,是许多初学者和专业开发者的必备读物。这个压缩包文件“java-resources-master”很可能包含了与学习和实践Java相关的各种...
在“java笔记之正则表达式”这篇笔记中,作者深入探讨了正则表达式的基本概念、操作方法以及在Java中的应用。 首先,正则表达式(Regular Expression)是一组符合特定规则的字符序列,主要用于字符串的查找、匹配、...
《中文版Thinking in Java 4th编程思想》是学习Java编程的重要参考资料,它深入浅出地介绍了面向对象编程的核心概念。下面将详细解读其中的主要知识点。 1. **对象导论** - **万物皆对象**:Java编程的核心是对象...