先看代码, package reflect; //Class Word public class Word implements OfficeAble{ public static void main(String[] args){ } public void start(){ System.out.println("word...start..."); } public Word(){ } } package reflect; //Class Excel public class E
/* * Hibernate, Relational Persistence for Idiomatic Java * * Copyright (c) 2010, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contri
协变 Java中的协变是指,当发生继承时,子类中重写父类的方法时,可以返回父类方法返回类型的子类型.比如: class SuperClass{} class SubClass extends SuperClass{} class Test{ @Override public SuperClass make(){ return new SuperClass(); } } class SubTest extends Test{ @Override public SubClass make(){ re
原文 What’s the difference between an interface and an abstract class in Java? It’s best to start answering this question with a brief definition of abstract classes and interfaces and then explore the differences between the two. A class must be decla
Class定义常量方法(推荐方法) //final修饰符 public final class Constants { //私有构造方法 private Constants() {} public static final int ConstantA = 100; public static final int ConstantB = 100; ...... } 采用“类.常量名”方法进行调用.需要私有化构造方法,避免创建该类的实例.同时不需让其他类继承该类. 如果多处需要访问工具类中定义的常量
1. Translating Java Classes to Scala Classes Example 1: # a class declaration in Java public class Book{} # Scala equivalent of a class declaration class Book Example 2: # a Java class with a Construtor public class Book{ private final int isbn; priv
Annotations They provide information that you need to fully describe your program, but that cannot be expressed in Java. In general the kind of annotations you add and what you do with them are entirely up to you. Java SE5 contains three generalpurpo