Java programming fourth edition notes

                                      Chapter II Everything is an object

Before understanding the question in mind: 1. What is the subject?

                                     2. The role of the object?

                                     3. How to use an object?

 

1. The data subject is both our world everything can be expressed in words, language is the data, so everything is an object. Heap objects are placed in the computer, (also located in RAM).

2. The class is an abstract object attributes. Objects are instances of classes. Property (global variables, local variables, etc.) are described in the object included in the class, a method class may be transmitted to the object, so the object receiving certain information.

3. Creating objects: eg: random a = new random ()

                 random is a random number category, a is a reference (variable), new random () i.e. open space object stored in the RAM.

                            eg: String s = new String ( "asdf") asdf is the object.

               One might ask String s = "asdf"; and above what is the difference?

Here have extended the basics classes and variables. There are eight major basic types, in fact, classes in Java, while the upper class is called random compliant data types.

Reference (variable) to create objects written into the basic types of variables and reference type variable.

Basic types of variables: int a = 10; a basic variable types, int basic type, the object 10.

Which are on the stack when the stored data,

Therefore, when operating in Java objects, objects that are not directly, but rather reference (variable) operation objects.

Chapter further comprising not mentioned part

  • Domain concepts (including Scope The scope, the scope and methods of object variables)
  • Class composition (fields and methods)
  • Detailed methods (parameters and return values)
  • The static keyword
  • Notes document

The static keyword: method is called if the static keyword static methods, and object association may need when you call the method, the direct class name method name.

If the variable is defined with a static, static int a = 10; i.e., a 10 would have been, will not change.

Published 14 original articles · won praise 8 · views 4746

Guess you like

Origin blog.csdn.net/qq_41223538/article/details/81427619