Vector和Stack

import java.util.*;
public class Test1 {
	public static void main(String[] args){
		Vector cc=new Vector();
		Sp sp1=new Sp("001","巧克力",20f);
		Sp sp2=new Sp("002","果脯",10f);
		
		cc.add(sp1);
		cc.add(sp2);
		
		for(int i=0;i<cc.size();i++){
			System.out.println(((Sp)cc.get(i)).getMingcheng());
		}
		
		System.out.println();

		Stack dd=new Stack();
		Sp sp3=new Sp("001","香蕉",20f);
		Sp sp4=new Sp("002","苹果",10f);
		
		dd.add(sp3);
		dd.add(sp4);
		
		for(int i=0;i<cc.size();i++){
			System.out.println(((Sp)dd.get(i)).getMingcheng());
		}
		
	}
}

class Sp{
	private String bianhao;
	private String mingcheng;
	private float jiage;

	Sp(String bianhao,String mingcheng,float jiage){
		this.bianhao=bianhao;
		this.mingcheng=mingcheng;
		this.jiage=jiage;
	}

	public String getBianhao() {
		return bianhao;
	}

	public void setBianhao(String bianhao) {
		this.bianhao = bianhao;
	}

	public String getMingcheng() {
		return mingcheng;
	}

	public void setMingcheng(String mingcheng) {
		this.mingcheng = mingcheng;
	}

	public float getJiage() {
		return jiage;
	}

	public void setJiage(float jiage) {
		this.jiage = jiage;
	}	
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值