JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java 新手區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 何時才須要declare static variables?
jimmyisking





發文: 22
積分: 0
於 2007-04-07 07:04 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
public class SeasonWinner
{
    private Schedule schedules;
    public static void main (String [] args)
    {
        SeasonWinner runn = new SeasonWinner ();
    }
public SeasonWinner ()
    {
        run ();
    }
public void run(){
  schedules = new Schedule ();
            System.out.println (Teams [i] + "  -  " + schedules.winRecord [i] + " wins,   " + schedules.looseRecord [i] + " losses,  " + schedules.Tie [i] + " ties =  " + sum [i]);
}
}
class Schedule 
{ 
public static final int GAMES = 20; 
public static String [] teamHome = new String [GAMES]; 
public static String [] teamAway = new String [GAMES]; 
public static int [] winRecord = new int [6]; // Records為什麼不是static 就不會計 
public static int [] looseRecord = new int [6];//為什麼不是static 就不會計 
public static int [] Tie = new int [6];//為什麼不是static 就不會計 
 
public String [] getTeams () 
{ 
String [] Teams = {"Calgary", "Vancouver", "Edmonton", "Toronto", "Ottawa", "Montreal"}; 
return Teams; 
} 
public Game getGame (int i) 
{ 
return new Game ("", "", 0, i); 
} 
} 
 
class Game 
{ 
private Schedule teams; 
public Game (String homeTeam, String awayTeam, int homeScore, int awayScore) 
{ 
} 
public void record () 
{ 
teams = new Schedule (); 
String [] match = teams.getTeams (); 
 
for (int i = 0 ; i < 6 ; i++) 
{ 
if (winner.equalsIgnoreCase (match [i])) 
{ 
teams.winRecord [i] += 1; 
} 
} 
} 

========================================
How come all the winning records of every team become "0" when I change public static int [] winRecord ==> public int [] winRecord.
何時才須要declare static variables?為什麼不是static 就不會計 winning record.
Thank you all~ Smile


jimmyisking edited on 2007-04-10 08:49
reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
3356 何時才須要declare static variables? jimmyisking 1695 2007-04-07 07:04
2708 Re:何時才須要declare static variables? kid1945 242 2007-04-10 05:32
2585 Re:何時才須要declare static variables? kid1945 109 2007-04-10 06:00
2536 Re:何時才須要declare static variables? jimmyisking 300 2007-04-10 06:06
2502 Re:何時才須要declare static variables? kid1945 551 2007-04-10 07:58
2471 Re:何時才須要declare static variables? jimmyisking 666 2007-04-10 08:43
2502 Re:何時才須要declare static variables? kid1945 678 2007-04-10 08:53
2453 Re:何時才須要declare static variables? kid1945 206 2007-04-10 09:08
2508 Re:何時才須要declare static variables? jimmyisking 872 2007-04-10 09:21
2463 Re:何時才須要declare static variables? kid1945 946 2007-04-10 09:29
2557 Re:何時才須要declare static variables? jimmyisking 210 2007-04-10 09:36
» JWorld@TW »  Java 新手區

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8