Berkeley CS61B (one/two)

Berkeley CS 61B (one—overview/two—compliation)

暑期在家给自己安排了一些课程,这是第一部分——Berkeley CS61B
CS61B涉及到数据结构,算法,还有面向对象编程java的相关内容,本专栏主要记录一些自己不熟悉以及认为重要的关键知识。

one:java

java is an object oriented language with strict requirements:
1:every java file must contain a class declaration
2:all code lives inside a class
3:to run a java program, you should define a main method using
(**public static void main(String [] args) **)

java is statically typed
1:all variables(变量)parameter(参量),and methods must have a declared type.
2:The type can never change.
3:Expressions(表达式) also have a type.
4:before the program runs, the compile will check all the types in you program are compatible.

java’s advantages and disadvantages
Not elaborated here

two:compilation

javac=compile(源文件的名称)-javac name.java
java=run(类名)java name1

如图

there:Defining and instantiating classes

to run a program we must define a main method
不能编译,因为没有主方法

Instantiating a class and Terminology

public class DogLauncher{
	public static void main(String[] args){
	Dog smallDog;
	/*Declaration of a Dog variable*/
	new Dod(20);
	/*instantiation of the Dog class as a Dog Object*/
	smallDog=new Dog(5);
	/*instantiation and assignment*/
	Dog hugeDog=new Dog(150);
	/*Declaration,instantiation and assignment/
	
	}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值