Java语法(三)JVM Spec(2) Concepts

本文详细介绍了Java虚拟机的概念,包括其作为抽象机器的特性、历史、类型与值、变量、Unicode、类型转换、命名与包、类、字段、方法、构造器、接口、数组、异常处理、类加载、实例创建、内存模型和线程等内容,旨在揭示Java编程语言的底层运行机制。
摘要由CSDN通过智能技术生成

摘自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"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值