码迷,mamicode.com
首页 > 编程语言 > 详细

java 容器

时间:2016-03-26 07:53:30      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:


package dplearn;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;


public class Learn {
	public static void main(String[] args){
		List myList=new ArrayList();
		Basicinfo myBasic=new Basicinfo("虎头牌笔记本",3.5f,"red");
	    myList.add(myBasic);
		myBasic=new Basicinfo("A4纸",3.5f,"white");
	    myList.add(myBasic);
		myBasic=new Basicinfo("B2铅笔",3.5f,"black");
	    myList.add(myBasic);
	    Iterator iterator=myList.iterator();
	    while (iterator.hasNext()){
	    	Basicinfo bsinfo=(Basicinfo)iterator.next();
	    	System.out.println(bsinfo.info());
	    }
	}
}


本博客所有内容是原创,如果转载请注明来源

http://blog.csdn.net/myhaspl/



package dplearn;

public class Basicinfo {
	String name;
	float price;
	String color;
	public Basicinfo(){
		name="";
	    price=0;
	    color="";
	}
	public Basicinfo(String name,float price,String color){
		this.name=name;
		this.price=price;
		this.color=color;
	}
	public String info(){
		return this.name+"=>"+this.price+"=>"+this.color;
	}
}


java 容器

标签:

原文地址:http://blog.csdn.net/myhaspl/article/details/50971904

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!