接受字符串[]的公共主方法

时间:2016-03-05 01:39:12

标签: java

我必须完成这项任务,基本上它会创建一副牌并对其进行随机播放,然后随机将牌分配给两个玩家并选择哪个牌总数更高。当我运行它时,我收到此错误:

  

no static void main方法接受String []

是什么导致了这个问题?

import java.util.*;

public class Main
{
    public static void Main(String[] args)
    {
        int hand1val = 0;
        int hand2val = 0;

        Deck deck = new Deck();
        ArrayList <Card> hand1 = new ArrayList <Card>();
        ArrayList <Card> hand2 = new ArrayList <Card>();

        for (int i = 0; i < 5; i++){
            hand1.set(i, deck.getTopCard());
            hand1val+= hand1.get(i).pointValue();
            hand2.set(i, deck.getTopCard());
            hand2val+= hand2.get(i).pointValue();
        }

        System.out.println("Hand 1: total points: " + hand1val);
        for (int i = 0; i < 5; i++ ){
            System.out.println(hand1.get(i));
        }

        System.out.println("Hand 1: total points: " + hand1val);
        for (int i = 0; i < 5; i++ ){
            System.out.println(hand1.get(i));
        }

        if(hand2val> hand1val)
        System.out.println("Hand 2 wins");
        else if (hand1val>hand2val)
        System.out.println("Hand 1 wins");

    }
}

1 个答案:

答案 0 :(得分:1)

资本化很重要。此

public static void Main(String[] args)

应该是

public static void main(String[] args)