标题:[求助]错在哪啊ArrayList
只看楼主
NiceGirl
Rank: 2
等 级:新手上路
威 望:4
帖 子:909
专家分:0
注 册:2006-6-18
 问题点数:0 回复次数:3 
[求助]错在哪啊ArrayList

import java.util.ArrayList;

class MailAddress
{
private String name;
private String street;
private String city;
private String country;
private long pinCode;

ArrayList store1 = new ArrayList();


MailAddress(String name1,String street1,String city1,String country1, long pinCode1)
{
name = name1;
street = street1;
city = city1;
country = country1;
pinCode = pinCode1;
}

public void store(MailAddress obj1,MailAddress obj2,MailAddress obj3)
{
store1.add(obj1);
store1.add(obj2);
store1.add(obj3);
}


public void show()
{

System.out.println("******************************************");
System.out.println("客户电子邮件地址");
System.out.println("*******************************************");
System.out.println();

System.out.println("[");


for(int i=0; i<store1.size(); i++)
{
System.out.println((chapter7p4)(store1.get(i)).name);
System.out.println((chapter7p4)(store1.get(i)).street);
System.out.println((chapter7p4)(store1.get(i)).city);
System.out.println((chapter7p4)(store1.get(i)).country);
System.out.println((chapter7p4)(store1.get(i)).pinCode);

if(store1.size() == i)
{
System.out.println(",");
}
}
System.out.println("]");
}
}


public class chapter7p4
{
public static void main(String args[])
{
MailAddress obj1 = new MailAddress("David Clarke","10 Downing","LondonState : London","United Kingdom",110022);
MailAddress obj2 = new MailAddress("John Lenon","12 Park Avenue","CaliforniaState : California","USA",210033);
MailAddress obj3 = new MailAddress("Stefii Graff","14 Maple Lane","MahomaState : Sydney","Australia",412033);

obj1.store(obj1,obj2,obj3);
obj1.show();
}
}

搜索更多相关主题的帖子: ArrayList String private city name 
2006-07-01 15:36
水影月圆
Rank: 4
等 级:贵宾
威 望:11
帖 子:738
专家分:0
注 册:2005-8-2
得分:0 
先看看chapter7p4类在什么地方

子非鱼,安知鱼之江湖?子非我,安知我之功夫 http://20681.
2006-07-01 15:44
千里冰封
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:灌水之王
等 级:版主
威 望:155
帖 子:28477
专家分:59
注 册:2006-2-26
得分:0 
光帖代码是不好用的,最好是把错误的信息也帖出来
你的代码所在的文件是不是叫chapter7p4.java,如果不是,那这就错得不应该

可惜不是你,陪我到最后
2006-07-02 10:15
NiceGirl
Rank: 2
等 级:新手上路
威 望:4
帖 子:909
专家分:0
注 册:2006-6-18
得分:0 
是类型转换错误,谢谢水影~!

曾经以为百般艰难,蓦然回首,才发现已飞渡千山。。!
2006-07-02 13:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-76069-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.343161 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved