小弟在JAVA论坛上出来乍到...还请各位多多包含.......
import java.util.*;
import java.io.*;
public class 第九题
{
private ArrayList c = new ArrayList();
public 第九题()
{
Student nick = new Student("Nick", "47043081", 100);
Student hebe = new Student("Hebe", "47043082", 100);
Student susan = new Student("Susan", "47043083", 100);
c.add(nick);
c.add(hebe);
c.add(susan);
printCollection(c);
Remove("47043083");
printCollection(c);
}
public void Remove(String sId)
{
for (int i = 0; i < c.size(); i++)
if ((Student)(c.get(i)).id.equals(sId))
c.remove(i);
}
public static void main(String[] args)throws IOException
{
new 第九题();
new BufferedReader(new InputStreamReader(System.in)).readLine();
}
private void printCollection(Collection c)
{
System.out.println("-------------------------");
Iterator it = c.iterator();
while (it.hasNext())
{
System.out.println(it.next());
}
System.out.println();
}
}
class Student
{
private String name;
public String id;
private int score;
public Student(String Name, String Id, int Score)
{
name = Name;
id = Id;
score = Score;
}
public String toString()
{
String s = id + "同学的姓名是:" + name + "\n成绩是:" + score;
return s;
}
public String xuehao()
{
return id;
}
public double sScore()
{
return score;
}
}
错误 1 在“Object”中找不到方法“xuehao()” C:\Documents and Settings\Administrator\桌面\Test\Test\Program.jsl 36 17 Test
但是我已经向下进行能够了强行转换.....
各位帮小弟看看...谢了