【Java基础】Java语言概述

1. Java 简介

Java是SUN(Stanford University Network - 斯坦福大学网络公司)在1995年推出的一种高级编程语言。Java是一种纯粹面向对象的编程语言。舍弃了C语言中的指针(以引用替代)、运算符重载(operator overloading)、多重继承(以接口取代),增加了垃圾回收器功能等。


2. Java 技术体系

- Java SE (Java Standard Edition) 标准版

支持Java桌面级应用,提供完整Java核心API,老版本为J2SE

- Java EE (Java Enterprise Edition) 企业版

提供企业级开发解决方案,主要针对Web应用,老版本为J2EE

- Java ME (Java Micro Edition) 小型版

精简了Java API,增加了移动端支持,老版本为J2ME

- Java Card

支持一些运行在小内存平台上的小程序(Applet)


3. Java 特点

- 面向对象

  • 相关概念:类,对象
  • 特性:封装,继承,多态

- 健壮性

- 跨平台性

“Write once, Run anywhere"
通过不同系统的JVM来运行Java


4. Java 核心机制

- Java虚拟机:JVM(Java Virtual Machine)

是一个虚拟的计算机,有指令集,使用不同的储存区域。负责执行指令,管理数据、内存、寄存器。不同操作系统有不同的JVM。
Java运行层级

- 垃圾回收机制(Garbage Collection)


5. JDK,JRE,JVM

- 全称

  • JDK: java development kit
  • JRE: java runtime environment
  • JVM: java virtual machine

- 关系

JDK = JRE + 开发工具集
JRE = JVM + Java SE 标准类库
在这里插入图片描述

6. Java 编写和运行

(1)编写和运行流程:

在这里插入图片描述

  1. 编写: java代码写到以 “.java” 为结尾的 源文件 里。
  2. 编译:“javac” 命令编译 源文件,将其转为 字节码文件
    javac 文件名.java
  3. 运行:“java” 运行 字节码文件
    java 类名

(2)注意

  • java 一个源文件 内,可以声明 多个类(class)
  • java一个源文件内,最多 只有 一个类 可以声明为 “public”,如果声明为public,则 类名源文件名 必须 一致
  • 编译后,会生成 一个或多个字节码文件,他们的 文件名 和源文件内的类名相同

7. Java程序入口-main方法

// main方法的格式是固定的
public static void main(String[] args){
	// codes
}

8. Java注释

1. 单行注释/多行注释

(1) 作用

  • 解释代码,供自己和他人理解代码
  • 调试代码

(2)形式

  • 单行注释
// 这是单行注释
  • 多行注释
/*
这是
多行
注释
*/

(3)特点

  • 注释内容不被编译(.class文件不包含注释信息)
  • 多行注释内不能有多行注释嵌套

2. 文档注释

(1)作用

  • 可使用 “javadoc” 自动生成网页形式的文档说明

(2)形式

/**
 * 这是一个class名叫hello java annotation
 * @author hoy
 * @version v1.0
 */
public class HelloJavaAnnotation{
    /**
     * 这是属性1
     */
    private String a1;

    /**
     * 这是构造器 constructor
     */
    public HelloJavaAnnotation(){

    }

    /**
     * 这是方法1
     */
    public void m1(){

    }

    /**
     * 这是方法2
     */
    public void m2(){

    }
}

生成网页文档:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

(3)生成方式

command:
javadoc -d documentName -author -version fileName.java

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
本资源包括以下内容: 1、从官方网站下载的全书代码 2、Modern.Compiler.Implementation.in.Java.Second.Edition.chm Last year you may have seen the Modern Compiler Implementation in C: Basic Techniques (1997) which was the preliminary edition of our new 1998 textbook, Modern Compiler Implementation in C. The new, expanded version of this textbook describes all phases of a modern compiler: lexical analysis, parsing, abstract syntax, semantic actions, intermediate representations, instruction selection via tree matching, dataflow analysis, graph-coloring register allocation, and runtime systems. It includes good coverage of current techniques in code generation and register allocation, as well as functional and object-oriented languages, that are missing from most books. In addition, more advanced chapters are now included so that it can be used as the basis for two-semester or graduate course. The most accepted and successful techniques are described in a concise way, rather than as an exhaustive catalog of every possible variant. Detailed descriptions of the interfaces between modules of a compiler are illustrated with actual C header files. The first part of the book, Fundamentals of Compilation, is suitable for a one-semester first course in compiler design. The second part, Advanced Topics, which includes the advanced chapters, covers the compilation of object-oriented and functional languages, garbage collection, loop optimizations, SSA form, loop scheduling, and optimization for cache-memory hierarchies. A unique feature of the book is a well designed compiler implementation project in Java, including front-end and 'high-tech' back-end phases, so that students can build a complete working compiler in one semester. Accompanying support software is available.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值