Java学习笔记(一)

张文泰 posted @ 2010年3月09日 20:26 in Code and Develop with tags java , 2622 阅读

Java是相当典型的OOP语言,其本身的实现方式就是抽象的类。相比于C所具有的过程性,Java在思考难度上要降低了不少。但是要实现一个好的Java代码还是很困难的。

Java中一切都是对象。除了一些特殊的基本类型,基本类型一共有boolean, char, byte, short, int, long, float, double, void几种。这些基本类型在操作上与一般的“类”有一些不同。这些基本类型在赋值的时候,执行的是内容的复制。虽然这些基本类型也有相应的包装器类型,但是基本类型的存在时必要的。基本类型和包装器类型之间可以相互直接转化。Java中还内置了BigInteger和BigDecimal类,这些都是很方便的高精度数字类。其中,BigInteger中的乘法采用了FFT乘法。

Java中有关于对象的变量我们都认为是“引用”。也就是说

String s = new String(“Hello World!”),t = new String(“Bad!”);

这里的s, t仅仅是一个引用,如果有

s = t;

那么仅仅是将s指向t。Java中的数组也是“引用”数组。要注意函数的参数传递中参数也是以引用的形式传递的。

Java的作用域和C/C++稍有不同,不允许以下的情况:

int x = 0;
for (int i = 0; i<n; i++) {
  int x = i;
}

也就是说,Java中不存在将变量作用域隐藏的做法,这里后一个x的定义是非法的。

Java会给基本类型赋初值,初值默认为0(这里是二进制意义上的0)。


本作品遵循“署名-非商业性使用-相同方式共享 3.0 Unported”协议,转载请注明来自richard-desktop
Creative Commons License
CBSE 7th Class Quest 说:
2022年9月19日 17:27

The Central Board of Secondary Education has issued sample model papers with study guides and prior years' old test previous papers in PDF format. CBSE 7th Class Question Paper For evaluation-1, evaluation-2, evaluation-3, and evaluation-4 exams held under Term-1, Term-2, Term-3, and Term-4 exams of Paper-1 & Paper-2 or Part-A & Part-B Section for all subjects of the course for all Hindi medium, English medium, Urdu medium, and another regional language student, the board has designed those CBSE 7th Class Model Paper 2023.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter