Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法编译java代码_Java_Compiler Errors - Fatal编程技术网

无法编译java代码

无法编译java代码,java,compiler-errors,Java,Compiler Errors,我在Eclipse中为一个简单的21点游戏编写了一个程序,它运行时没有任何问题。然而,当我尝试在pico编辑器中使用javac编译时,它不会编译。为什么Eclipse不说编译错误在哪里?代码如下 import java.util.Scanner; import java.util.Random; public class Blackjack { public static void main(String args[]) { Scanner keybo

我在Eclipse中为一个简单的21点游戏编写了一个程序,它运行时没有任何问题。然而,当我尝试在pico编辑器中使用javac编译时,它不会编译。为什么Eclipse不说编译错误在哪里?代码如下

import java.util.Scanner;

import java.util.Random;

public class Blackjack {

     public static void main(String args[])
     {
         Scanner keyboard = new Scanner(System.in);
         Random randomGenerator = new Random();
         int nextCard;
         boolean keepPlaying = true;
         boolean playAgain = true;
         char hit;
         int DECK_MAX = 10;

         //This is the main loop to play the entire game
         while (playAgain == true)
         {
             int userCard1 = randomGenerator.nextInt(DECK_MAX) + 1;
             int userCard2 = randomGenerator.nextInt(DECK_MAX) + 1;
             int userTotal = userCard1 + userCard2;
             int dealerCard1 = randomGenerator.nextInt(DECK_MAX) + 1;
             int dealerCard2 = randomGenerator.nextInt(DECK_MAX) + 1;
             int dealerTotal = dealerCard1 + dealerCard2;

             //This deals the first two cards to the user, and prints the total
             System.out.println("Welcome to the CCSF Casino! Lets play...");
             System.out.println("Your first cards are " + userCard1 + " and " + userCard2);
             System.out.println("You have a total of " + userTotal);

             //The following checks three scenarios that can end the game on the first deal
             if (userTotal == 21 && dealerTotal == 21) 
             {
                 System.out.println("Both you and the dealer have 21. It's a push.");
                 keepPlaying = false;
             }
             if (userTotal != 21 && dealerTotal == 21)
             {
                 System.out.println("The dealer was dealt 21. You lose.");
                 keepPlaying = false;
             }
             if (userTotal == 21 && dealerTotal != 21)
             {
                 System.out.println("You have 21. You win!");
                 keepPlaying = false;
             }

             //The following checks if the game should continue to user interaction phase, and takes user input if so
             if (keepPlaying == true)
             {
                 System.out.println("The dealer is showing " + dealerCard1 + " with one card face down.");

                 //The following asks the user if they want to keep hitting as long as their total is less than 21
                 while (userTotal < 21)
                 {
                     System.out.println("Would you like another card(y/n)?");
                     hit = keyboard.next().charAt(0);
                     if (hit == 'y')
                     {
                         nextCard = randomGenerator.nextInt(DECK_MAX) + 1; 
                         userTotal += nextCard;
                         System.out.println("You were dealt a " + nextCard + " for a total of " + userTotal);

                         if(userTotal > 21)
                         {
                             System.out.println("You bust and lose. Sorry...");
                             keepPlaying = false;
                             break;
                         }
                     }
                     else
                         break;
                 } 
             }


             //The following checks if the game should continue to the dealer interaction phase. If so, it hits until dealer has > 17
             if (keepPlaying == true)
             {
                 System.out.println("The dealer's current total is " + dealerTotal);

                 while (dealerTotal < 17)
                 {
                     nextCard = randomGenerator.nextInt(DECK_MAX) + 1;
                     dealerTotal += nextCard;
                     System.out.println("Dealer has been dealt a " + nextCard + " for a total of " + dealerTotal);

                     if (dealerTotal > 21)
                     {
                         System.out.println("The dealer busts. You win!");
                         keepPlaying = false;
                         break;
                     }
                 }
             }

             //The following checks if the game should continue into the comparison phase. If so, it determines whether the dealer of user win
             if (keepPlaying == true)
             {
                 if (userTotal > dealerTotal)

                     System.out.println("You win! You had " + userTotal + " and dealer only had " + dealerTotal);

                 if (userTotal  < dealerTotal)
                     System.out.println("You lose...You only had " + userTotal + " and dealer had " + dealerTotal);

                 if (userTotal == dealerTotal)
                     System.out.println("It's a push!");
             }

             System.out.println("Would you like to play again(y/n)?");
             if (keyboard.next().charAt(0) == 'y')
             {   playAgain = true;
                 keepPlaying = true;
             }
             else
             {
                 System.out.println("Don't let the door hit you on the way out!");
                 break;
             }
         }

     }
}

对不起,大家,但问题最终与我没有正确地将文件名保存在我用于javac的ssh上有关。我不是想浪费你的时间,我很感激你的意见。在带到这里之前,请确保在将来更仔细地查看。

javac说了什么?换句话说,请发布完整的编译器错误消息,并指出哪些行导致了问题。userTotal和DealTotal都不会是21。最多20个。第一条错误消息显示用户的总数。我看不到代码中的文本。请重试。您正在编译的代码可能不是您在此处显示的代码。
Blackjack.java:23: error: not a statement
total for user
^
Blackjack.java:23: error: ';' expected
total for user
     ^
Blackjack.java:23: error: '(' expected
total for user
         ^
Blackjack.java:23: error: not a statement
total for user
          ^
Blackjack.java:23: error: ';' expected
total for user
              ^
Blackjack.java:24: error: '.class' expected
                         int dealerCard1 =
                             ^
Blackjack.java:24: error: illegal start of expression
                         int dealerCard1 =
                                         ^
Blackjack.java:24: error: ')' expected
                         int dealerCard1 =
                                          ^
Blackjack.java:25: error: illegal start of expression
randomGenerator.nextInt(DECK_MAX) + 1; //first card for dealer
               ^
Blackjack.java:25: error: ';' expected
randomGenerator.nextInt(DECK_MAX) + 1; //first card for dealer
                       ^
Blackjack.java:25: error: variable declaration not allowed here
randomGenerator.nextInt(DECK_MAX) + 1; //first card for dealer
                ^
Blackjack.java:25: error: not a statement
randomGenerator.nextInt(DECK_MAX) + 1; //first card for dealer
                        ^
Blackjack.java:25: error: ';' expected
randomGenerator.nextInt(DECK_MAX) + 1; //first card for dealer
                                ^
Blackjack.java:32: error: ';' expected
prints the total
          ^
Blackjack.java:33: error: ';' expected
                         System.out.println("Welcome to the CCSF Casino!
                               ^
Blackjack.java:33: error: unclosed string literal
                         System.out.println("Welcome to the CCSF Casino!
                                            ^
Blackjack.java:33: error: ';' expected
                         System.out.println("Welcome to the CCSF Casino!
                                                                         ^
Blackjack.java:34: error: not a statement
Lets play...");
     ^
Blackjack.java:34: error: ';' expected
Lets play...");
         ^
Blackjack.java:34: error: unclosed string literal
Lets play...");
            ^
Blackjack.java:41: error: ';' expected
end the game on the first deal
       ^
Blackjack.java:41: error: ';' expected
end the game on the first deal
               ^
Blackjack.java:41: error: ';' expected
end the game on the first deal
                         ^
Blackjack.java:41: error: not a statement
end the game on the first deal
                          ^
Blackjack.java:41: error: ';' expected
end the game on the first deal
                              ^
Blackjack.java:43: error: ';' expected
the user and dealer were both dealt 21, it's a push and the game ends
        ^
Blackjack.java:43: error: variable declaration not allowed here
the user and dealer were both dealt 21, it's a push and the game ends
    ^
Blackjack.java:43: error: ';' expected
the user and dealer were both dealt 21, it's a push and the game ends
                   ^
Blackjack.java:43: error: ';' expected
the user and dealer were both dealt 21, it's a push and the game ends
                             ^
Blackjack.java:43: error: not a statement
the user and dealer were both dealt 21, it's a push and the game ends
                              ^
Blackjack.java:43: error: ';' expected
the user and dealer were both dealt 21, it's a push and the game ends
                                   ^
Blackjack.java:43: error: unclosed character literal
the user and dealer were both dealt 21, it's a push and the game ends
                                          ^
Blackjack.java:43: error: not a statement
the user and dealer were both dealt 21, it's a push and the game ends
                                        ^
Blackjack.java:43: error: ';' expected
the user and dealer were both dealt 21, it's a push and the game ends
                                                   ^
Blackjack.java:43: error: ';' expected
the user and dealer were both dealt 21, it's a push and the game ends
                                                           ^
Blackjack.java:43: error: ';' expected
the user and dealer were both dealt 21, it's a push and the game ends
                                                                     ^
Blackjack.java:45: error: unclosed string literal
                                 System.out.println("Both you and the
                                                    ^
Blackjack.java:45: error: ';' expected
                                 System.out.println("Both you and the
                                                                      ^
Blackjack.java:46: error: not a statement
dealer have 21. It's a push.");
       ^
Blackjack.java:46: error: ';' expected
dealer have 21. It's a push.");
           ^
Blackjack.java:46: error: unclosed character literal
dealer have 21. It's a push.");
                  ^
Blackjack.java:46: error: not a statement
dealer have 21. It's a push.");
                ^
Blackjack.java:46: error: ';' expected
dealer have 21. It's a push.");
                           ^
Blackjack.java:46: error: unclosed string literal
dealer have 21. It's a push.");
                            ^
Blackjack.java:50: error: ';' expected
the dealer was dealt 21 and the user wasn't, user loses and the game ends
          ^
Blackjack.java:50: error: variable declaration not allowed here
the dealer was dealt 21 and the user wasn't, user loses and the game ends
    ^
Blackjack.java:50: error: ';' expected
the dealer was dealt 21 and the user wasn't, user loses and the game ends
                    ^
Blackjack.java:50: error: ';' expected
the dealer was dealt 21 and the user wasn't, user loses and the game ends
                               ^
Blackjack.java:50: error: unclosed character literal
the dealer was dealt 21 and the user wasn't, user loses and the game ends
                                         ^
Blackjack.java:50: error: ';' expected
the dealer was dealt 21 and the user wasn't, user loses and the game ends
                                                       ^
Blackjack.java:50: error: ';' expected
the dealer was dealt 21 and the user wasn't, user loses and the game ends
                                                               ^
Blackjack.java:50: error: ';' expected
the dealer was dealt 21 and the user wasn't, user loses and the game ends
                                                                         ^
Blackjack.java:52: error: unclosed string literal
                                 System.out.println("The dealer was dealt
                                                    ^
Blackjack.java:52: error: ';' expected
                                 System.out.println("The dealer was dealt
                                                                          ^
Blackjack.java:53: error: ';' expected
21. You lose.");
            ^
Blackjack.java:53: error: unclosed string literal
21. You lose.");
             ^
Blackjack.java:57: error: ';' expected
the user got 21 and the dealer didn't, user wins and game ends
        ^
Blackjack.java:57: error: variable declaration not allowed here
the user got 21 and the dealer didn't, user wins and game ends
    ^
Blackjack.java:57: error: not a statement
the user got 21 and the dealer didn't, user wins and game ends
         ^
Blackjack.java:57: error: ';' expected
the user got 21 and the dealer didn't, user wins and game ends
            ^
Blackjack.java:57: error: ';' expected
the user got 21 and the dealer didn't, user wins and game ends
                       ^
Blackjack.java:57: error: unclosed character literal
the user got 21 and the dealer didn't, user wins and game ends
                                   ^
Blackjack.java:57: error: ';' expected
the user got 21 and the dealer didn't, user wins and game ends
                                                ^
Blackjack.java:57: error: ';' expected
the user got 21 and the dealer didn't, user wins and game ends
                                                         ^
Blackjack.java:57: error: not a statement
the user got 21 and the dealer didn't, user wins and game ends
                                                          ^
Blackjack.java:57: error: ';' expected
the user got 21 and the dealer didn't, user wins and game ends
                                                              ^
Blackjack.java:59: error: unclosed string literal
                                 System.out.println("You have 21. You
                                                    ^
Blackjack.java:59: error: ';' expected
                                 System.out.println("You have 21. You
                                                                      ^
Blackjack.java:60: error: unclosed string literal
win!");
    ^
Blackjack.java:60: error: not a statement
win!");
   ^
Blackjack.java:65: error: ';' expected
continue to user interaction phase, and takes user input if so
           ^
Blackjack.java:65: error: ';' expected
continue to user interaction phase, and takes user input if so
                            ^
Blackjack.java:65: error: not a statement
continue to user interaction phase, and takes user input if so
                             ^
Blackjack.java:65: error: ';' expected
continue to user interaction phase, and takes user input if so
                                  ^
Blackjack.java:65: error: ';' expected
continue to user interaction phase, and takes user input if so
                                             ^
Blackjack.java:65: error: ';' expected
continue to user interaction phase, and takes user input if so
                                                        ^
Blackjack.java:65: error: '(' expected
continue to user interaction phase, and takes user input if so
                                                           ^
Blackjack.java:65: error: ')' expected
continue to user interaction phase, and takes user input if so
                                                              ^
Blackjack.java:68: error: unclosed string literal
                                 System.out.println("The dealer is showing
                                                    ^
Blackjack.java:68: error: ';' expected
                                 System.out.println("The dealer is showing
                                                                           ^
Blackjack.java:69: error: ';' expected
" + dealerCard1 + " with one card face down.");
                            ^
Blackjack.java:69: error: ';' expected
" + dealerCard1 + " with one card face down.");
                                      ^
Blackjack.java:69: error: unclosed string literal
" + dealerCard1 + " with one card face down.");
                                            ^
Blackjack.java:69: error: not a statement
" + dealerCard1 + " with one card face down.");
                                           ^
Blackjack.java:72: error: ';' expected
want to keep hitting as long as their total is less than 21
       ^
Blackjack.java:72: error: ';' expected
want to keep hitting as long as their total is less than 21
                    ^
Blackjack.java:72: error: not a statement
want to keep hitting as long as their total is less than 21
                     ^
Blackjack.java:72: error: ';' expected
want to keep hitting as long as their total is less than 21
                       ^
Blackjack.java:72: error: ';' expected
want to keep hitting as long as their total is less than 21
                               ^
Blackjack.java:72: error: ';' expected
want to keep hitting as long as their total is less than 21
                                           ^
Blackjack.java:72: error: ';' expected
want to keep hitting as long as their total is less than 21
                                                   ^
Blackjack.java:72: error: not a statement
want to keep hitting as long as their total is less than 21
                                                    ^
Blackjack.java:72: error: ';' expected
want to keep hitting as long as their total is less than 21
                                                        ^
Blackjack.java:75: error: unclosed string literal
                                         System.out.println("Would you
                                                            ^
Blackjack.java:75: error: ';' expected
                                         System.out.println("Would you
                                                                       ^
Blackjack.java:76: error: ';' expected
like another card(y/n)?");
                 ^
Blackjack.java:76: error: not a statement
like another card(y/n)?");
                   ^
Blackjack.java:76: error: ';' expected
like another card(y/n)?");
                     ^
Blackjack.java:76: error: unclosed string literal
like another card(y/n)?");
                       ^
Blackjack.java:84: error: unclosed string literal
                                                 System.out.println("You
                                                                    ^
100 errors