易截截图软件、单文件、免安装、纯绿色、仅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语言(一)

 一  类
     类是java中的一种重要的复合数据类型,是组成java程序的基本要素。它封装了一类对象的状态和方法,是这一类对象的原形。一个类的实现包括两个部分:类声明和类体
1.类声明:
  [public][abstract|final]
class className [extends superclassName] [implements
inte ......

JAVA连接数据库大全

 oracle
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
String user="scott";
String password="tiger";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_S ......

java第9天课堂笔记 (Set)

1、set集合是最简单的一种集合,集合中不按指定的方式排序,并且没有重复对象。
2、set接口主要有两个实现类:HashSet和TreeSet
   (1)HashSet:是按照哈希算法来进行存取集合中的对象,存取的速度比较快。
   (2)TreeSet:实现了SortedSet接口,具有排序的功能。
3、HashSet类是按照哈希算法来存取 ......

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 ......

Java学习笔记(2)体验云计算


      现在,谈云计算的可多了,不过,一般比较关注的是Google和Amazon的云服务。从大范围来看,也只有这两家获得了公众的更多关注。比如,我个人很感兴趣的,就是Google的App Engine使用户能够在Google基础设施上构建和托管 Web 应用程序。至于Amazon,它的AmazonWeb Services还包括Elastic Clou ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号