易截截图软件、单文件、免安装、纯绿色、仅160KB

Java: class , objects

Java: class , objects
1 Inheritance(继承)的关键字extends
class MountainBike extends Bicycle {
}
但是不能多重继承。不过可以通过implements多个interface来实现类似的东西
2 interface
interface Bicycle {
       void changeCadence(int newValue);   // wheel revolutions per minute
       void changeGear(int newValue);
       void speedUp(int increment);
       void applyBrakes(int decrement);
}
class ACMEBicycle implements Bicycle {
   // remainder of this class implemented as before
}
可实现(implements)多个interface
class MyClass extends MySuperClass implements YourInterface {
    //field, constructor, and method declarations
}
means that MyClass is a subclass of MySuperClass and that it implements the YourInterface interface
3 package
A package is a namespace that organizes a set of related classes and interfaces.
4 Access Modifier
public, private, protected
public class Bicycle {
     private int cadence;
     public int aag;
     public void test();
}
每个field或method都必须单独修饰
 
Access Levels
ModifierClassPackageSubclassWorld
public
Y
Y
Y
Y
protected
Y
Y
Y
N
no modifier
Y
Y
N
N
private
Y
N
N
N
约定:
class 名字的第一个字母大写; method第一个word是动词
5 Constructors
The compiler automatically provides a no-argument, default constructor for any class without constructors.
This default constructor will call the no-argument constructor of the superclass.
6 method & parameter
The Java programming language doesn't let you pass methods into methods. But you can pass an object into a method and then invoke the object's methods.
 can Returning a Class or Interface??
7 this : current object
public class Point {
public int x = 0; //field可以这样初始化
public int y = 0;


相关文档:

针对 Java 开发人员的 Dojo 概念

 
Dojo 在基于Web 的应用程序中越来越受到欢迎。很多开发人员是 Java™ 编程方面的能手,但是在 JavaScript
方面却缺乏经验。从强类型、面向对象的编译语言转向动态的、弱类型脚本语言,开发人员需要经历概念跃迁带来的困难。这种混乱使开发人员很难正确地声明
Dojo 类。本文将帮助梳理这种混乱,解释为何必须 ......

深刻理解Java编程的7个例子

 深刻理解Java编程的7个例子   佟强 2009年11月7日 http://blog.csdn.net/microtong
 1. 阅读下列代码回答问题(第一个Java程序,理解PATH和CLASSPATH,学会使用javac和java命令)
view plaincopy to clipboardprint?
package cn.edu.uibe;  
public class HelloWorld {  
......

java第9天代码(集合类)

/**********Customer .java   begin***********/
import java.util.HashSet;
import java.util.Set;
/**
 * 如果两个Customer对象nama属性和age属性相同,那么这两个Customer对象相等。
 * @author Administrator
 *
 */
public class Customer {
 
 private String nam ......

C语言和JAVA一样,函数参数传递方式都为值传递方式

定义按值传递和按引用传递这两个术语是重要的。
按值传递意味着当将一个参数传递给一个函数时,函数接收的是参数的一个副本。因此,如 果函数修改了该参数,仅改变副本,而原始值保持不变。按引用传递意味着当将一个参数传递给一个函数时,函数接收的是参数的内存地址,而不是参数的副本。因 此,如果函数修改了该参数,调 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号