- 浏览: 259096 次
- 性别:
- 来自: 大连
-
文章分类
最新评论
-
saishangxue123:
文章写的清楚、明了,一气呵成,支持
什么是反射、反射能干什么、如何使用反射? -
allen3010:
1,2,3,4,5这六个数字。。。。。
用1、2、2、3、4、5这六个数字,用java写一个main函数,打印出所有不同的排列
import java.util.Calendar; class Product { //一般商品类 String productName; //名称 double price; //价格 String ID; //编号 String unit; //单价 public Product(String ID,String productName,double price,String unit){ //父类构造函数 this.ID = ID; this.productName = productName; this.price = price; this.unit = unit; } public String getProductName(){ return this.productName; } public double getPrice(){ return this.price; } public String getID(){ return this.ID; } public String getUnit(){ return this.unit; } public String toString(){ return "商品ID为:"+this.ID+"\t商品名称为:"+this.productName+"价格:"+this.price+"单位:"+this.unit; } } public class DiscountedProduct11 extends Product{ private Calendar startDate; private Calendar endDate; private double discount; //折扣 public DiscountedProduct11(String ID,String productName,double price,String unit, Calendar startDate,Calendar endDate,double discount){ //子类构造函数 super(ID,productName,price,unit); //**************************** this.startDate = startDate; this.endDate = endDate; this.discount = discount; } public Calendar getStartDate(){ return this.startDate; } public Calendar getEndDate(){ return this.endDate; } public double getDiscount(){ return this.discount; } public String toString(){ return "商品ID为:"+this.ID+"\n商品名称为:"+this.productName+"\n价格:"+this.price+"\n单位:"+this.unit+ "\n开始时间为:"+this.startDate.getTime()+"\n结束时间为:"+this.endDate.getTime()+"\n折扣率为:"+this.discount; } public static void main(String args[]){ System.out.println("当前时间为:"); Calendar cal = Calendar.getInstance(); System.out.println(cal.getTime()); //获得当前时间 Calendar cal2=Calendar.getInstance(); cal2.set(Calendar.MONDAY, 10); //修改时间属性 System.out.println("*****************************************"); DiscountedProduct11 DP = new DiscountedProduct11("001","苹果",2.0,"/kg",cal,cal2,0.2); System.out.println(DP); System.out.println("*****************************************"); Product p = new DiscountedProduct11("002","香蕉",3.0,"/kg",cal,cal2,0.3); //upcasting System.out.println(p); } }
发表评论
-
java时间大小比较
2015-04-02 21:48 973摘自: http://blog.sina.com.cn/s/b ... -
StringBuffer的常用方法
2015-03-30 16:06 966摘自:http://blog.csdn.net/deaful/ ... -
什么是反射、反射能干什么、如何使用反射?
2013-08-16 00:03 4842//来源互联网 一、什 ... -
Class.forName···关于Class. 的应用介绍
2013-08-15 23:36 1160//摘自互联网 Class.forName(xxx.xx ... -
java泛型map的用法(转2)
2013-07-25 23:04 91921.声明一个map: Map map = ne ... -
java泛型map的用法(转)
2013-07-25 22:56 3117http://www.apkbus.com/blog-2079 ... -
关于日期 Date Calendar
2013-07-23 22:46 1131import java.security.Timestam ... -
正则表达式 例子
2013-07-22 23:00 829import java.util.regex.Matche ... -
Iterator的使用方法
2013-07-18 21:45 0import java.util.*; publ ... -
泛型的写法种种
2013-07-18 21:41 1031public class Generics<T> ... -
ArrayList ,LinkedList, TreeSet的使用方法
2013-07-18 21:35 2323import java.util.*; public ... -
Stack的使用方法
2013-07-18 21:26 1374import java.util.Stack; ... -
Hashtable的使用方法介绍
2013-07-18 21:24 22941**************************** ... -
老式枚举的使用方法
2013-07-18 21:23 951import java.util.Enumeration; ... -
java中Map的各种排序介绍
2013-07-14 13:24 1734//本篇来源于互联网 HashMap: 最常用的Ma ... -
java配置文件用法
2013-04-14 22:43 1309package cn.com.mfsoft.config; ... -
java利用反射得到实例
2013-04-10 22:44 1278对于面向接口编程的项目免不了要一反射相接触,动态得到实例: ... -
spring的beanFactory和factoryBean
2013-04-05 16:10 2127spring的beanFactory和factoryBe ... -
Spring配置文件总结
2013-04-05 16:05 892Spring配置文件总结(转) 2010-06-07 23: ... -
Spring 的微内核与FactoryBean扩展机制
2013-04-05 15:49 1596Spring 的微内核与FactoryBean扩展机制 ...
相关推荐
countdownlatch-example-sourcecode.zip
1、再谈向上类型转换(upcasting) 忘记对象的类型 2、多态机理 方法绑定(method binding) 产生正确的行为 可扩展性 陷阱:置换私有方法 3、抽象类与抽象方法 4、构造方法与多态 构造方法的...
Java SE5 and SE6 .................. 2 Java SE6 ......................................... 2 The 4th edition........................ 2 Changes .......................................... 3 Note on the ...
多态 ->1.多态概念 ->2.类型转换(upcasting&downcasting) ->3.动态绑定 ->4.抽象类 ->5.实例讲解
继承包括继承中的存取控制、构造、析构的调用顺序、私有继承、运算符重载与继承、upcasting等。 八、多态性与虚函数 多态性是C++语言中的一种机制,它允许一个对象在运行时确定其类型。多态性包括 早/晚绑定、虚...