摘自The JavaTM Virtual Machine Specification
jconsole.exe自带的工具
at compile time at run time
2 Java Concepts
This book describes Version 1.0.2 of the Java Virtual Machine
This book specifies an abstract machine. It does not document any particular implementation of the Java Virtual Machine, including Sun's.
The Java Virtual Machine is an abstract design
The original Java Virtual Machine was designed by James Gosling in 1992.
The Java Virtual Machine is an abstract computing machine. Like a real computing machine, it has an instruction set and uses various memory areas.
The Java Virtual Machine knows nothing of the Java programming language, only of a particular file format, the class file format. A class file contains Java Virtual Machine instructions (or bytecodes) and a symbol table, as well as other ancillary information.
2.1 Unicode
Except for(除了) comments and identifiers (§2.2) and the contents of character and string literals (§2.3), all input elements in a Java program are formed from only ASCII characters.
2.4 Types and Values
Java is a strongly typed language, which means that every variable and every expression has a type that is known at compile time.
The types of the Java language are divided into two categories: primitive types and reference types
Primitive values do not share state with other primitive values
There are three kinds of reference types: the class types , the interface types , and the array types.
2.5 Variables
A variable is a storage location. It has an associated type, sometimes called its compile-time type
There are seven kinds of variables:
1、A class variable is a field of a class type declared using the keyword static within a class declaration, or with or without the keyword static in an interface declaration.
Class variables are created when the class or interface is loaded and are initialized on creation to default values.(引用类型变量初始化值为null)
2、An instance variable is a field declared within a class declaration.an instance variable is created and initialized to a default value (§2.5.1) as part of each newly created object of class T or of any class that is a subclass of T.
3、Array components are unnamed variables that are created and initialized to default values (§2.5.1) whenever a new object that is an array is created .
4、Method parameters name argument values passed to a method. a new parameter variable is created each time that method is invoked. The new variable is initialized with the corresponding argument value from the method invocation.
5、Constructor parameters name argument values passed to a constructor. 类似method parameters
6、An exception-handler parameter variable is created each time an exception is caught by a catch clause of a try statement. The new variable is initialized with the actual object associated with the exception 。
7、Local variables are declared by local variable declaration statements. 本地局部变量.A local variable must be explicitly given a value before it is used。因为它没有其他途径赋值,比如没有get方法。
共7中变量,2种大类型type,4种小类型。
Every variable in a Java program must have a value before it is used:
An object is said to be an instance of its class and of all superclasses of its class. Sometimes the class of an object is called its "runtime type(is a compile-time notion)
The type of a variable is always declared, and the type of an expression can be deduced at compile time
Every array also has a class. The classes for arrays have strange names that are not valid Java identifiers; for example, the class for an array of int components has the name "[I"