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应用的快速Web服务支持工具 - Netrifex
Proxisoft今天宣布Netrifex 1.0版。
Netrifex可以立即把Web Services添加到现有的Java SE和Java EE应用程序,从而实现把Web Services快速、低费用的部署到整个企业应用。
Netrifex增加Web Services到现有的Java应用中。该产品使用户能够:
* 快速创建Web Service ......
JAVA语言中的反射机制:
在Java 运行时 环境中,对于任意一个类,能否知道这个类有哪些属性和方法?
对于任意一个对象,能否调用他的方法?这些答案是肯定的,这种动态获取类的信息,以及动态调用类的方法的功能来源于JAVA的反射。从而使java具有动态语言的特性。
JA ......
使用Java ME技术开发手机密码管理软件
陈跃峰
摘要:Java ME技术是3G开发主流的技术之一,本文将通过系统的方式介绍如何使用Java ME技术开发密码管理软件,使大家能够通过该文章快速熟悉Java ME技术,进入3G移动程序开发的大门!
关键字:Java ME 手机 密码 管理 记录存储
......
/**********Customer .java begin***********/
import java.util.HashSet;
import java.util.Set;
/**
* 如果两个Customer对象nama属性和age属性相同,那么这两个Customer对象相等。
* @author Administrator
*
*/
public class Customer {
private String nam ......
现在,谈云计算的可多了,不过,一般比较关注的是Google和Amazon的云服务。从大范围来看,也只有这两家获得了公众的更多关注。比如,我个人很感兴趣的,就是Google的App Engine使用户能够在Google基础设施上构建和托管 Web 应用程序。至于Amazon,它的AmazonWeb Services还包括Elastic Clou ......