Görevim, metin dosyasındaki eşleşme sonucundan okumak ve onu bir array
içine koymaktır. Ancak takım performansını hesaplamak için maç sonucunu kullanmalıyım. Bunu yapmak için result
'un veri türünü string
dizisinde int[]
'a dönüştürmem gerekiyor.Dizede, tamsayı dizisine dize kaydetme
Bu konuda bana yardımcı olan var mı?
public LeagueMatch()
{
}
public LeagueMatch(String teamName, int[] result, String date, String opponent, int attendance,double ticketPrice,int awayFans) {
this.teamName = teamName;
this.result = result;
this.date = date;
this.opponent = opponent;
this.attendance = attendance;
this.ticketPrice = ticketPrice;
this.awayFans = awayFans;
}
public LeagueMatch(String m)
{
this.result = new int[2];
String[] d = m.split(",");
this.teamName=d[0];
this.result=(d[1]); //there is an error here
this.date=d[2];
this.opponent=d[3];
this.attendance=Integer.parseInt(d[4]);
this.ticketPrice=Double.parseDouble(d[5]);
this.awayFans=Integer.parseInt(d[6]);
}
Kullanım Integer.parseInt (d [1]); – amitguptageek
StackOverflow'a hoş geldiniz. Lütfen [Yardım merkezi] 'de (http://stackoverflow.com/help) soru sormak için yönergeleri okumak için bir dakikanızı ayırın. – jbm