翁恺java语言_【Java学习】翁恺java语言听讲笔记

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

第二讲

Java环境

(图)

由java源程序 编译为 字节码文件 java虚拟机中执行 平台可以是linux,windows,Mac

跨平台/可移植

*Cross Platform/Portable Portable:the dream from UNIX and C to Java

\jvm

\Unique data type

\\int:32-bit

\\Char:Unicode

Capacity:high or low?

*Low:

\Interpreted

\Code check

\Stack machine

*High

\JIT

\Mutil-thread

\Byte code simple design

*No point 没有指针没有delete,java有垃圾搜集机制

*Index check有下标检查,确保不越界

*Auto memory management

安装jdk环境:控制面板-系统-高级-环境变量-path:之前加上路径

测试环境:运行-cmd-敲入:java -version回车

Simple:KISS

*c++ like

*no point

*Auto memory check

Pure OOP纯的OOP语言

*Java=C++--

\mutil-inheritance多继承

\virtual inheritance虚继承

\template模板

\operator overloading运算符重载

Dynamic

*java没有传统的程序的概念

*java认为全世界的类和对象是一个空间

*你写的程序的编译结果是这个空间的一部分

*所谓的运行程序就是从空间中某类的某个特殊的方法开始启动

root

*every class in java is a descendant of one class:object

*so all objects in java is objects of the class object

*in this way,container is an object that can hold objects.

handle

*you can not hold the object itself,instead,you can have a handle that refer to it.

String s;

*here s is only a handle that refer to nothing.

String s=new String("a string");

An object of String is created

the object is initialized w/"a string"

a variable as handle to String is created

the value of the handle variable is assign to the object

/*第一个字母大写,表示是一个类*/

first java program

class helloworld{

public statci void main(String[] args){

System.out.println("Hello World!");

}

}

在记事本中写程序,然后保存为HelloWorld.java的文件

在cmd.exe 下面进行编译

输入java HelloWorld回车

显示Hello World!

输入java HelloWorld.classl回车,则会报

exception in thread "main" java.lang.NoClassDefFoundError:HelloWorld/class


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部