2014-09-06 42 views
-4
import java.io.*; 
    public class StringInput{ 
    public static void main (String args[]);{ 
     String Name "StringInput"; 
     System.out.print ("Enter your name: "); 
     InputStreamReader input = new InputStreamReader(System.in); 
      InputStreamReader reader = new BufferedReader(input); 
       name = reader.readline(); 
       catchException e;{ 
      }//Exception 
      System.out.println ("Hello"+Name+"How are you?"); 
    }//main 
}//class 

這是我正在做的代碼,theres一個錯誤。第4行,我無法弄清楚它是什麼。字符串輸入行4錯誤,我似乎無法弄清楚它是什麼

我們在課堂上(我剛開始計算機編程12),我們沒有時間完成它和一切。

如果有人能幫我弄清楚第4行有什麼問題,那真的很有幫助。

謝謝! :)

刪除了分號,仍然得到String Name「StringInput」; ^ 1錯誤

過程完成。

+0

'(String args []); {'刪除分號。 – August 2014-09-06 06:02:42

回答

1

取出後主要方法分號(;):

更改此:

public static void main (String args[]);{ 

public static void main (String args[]) { 

在你的代碼的另一種錯誤與try/catch語句用法:

更改此項:

name = reader.readline(); 
      catchException e;{ 
     }//Exception 

try { 
     name = reader.readline(); 
    catch(Exception e){ 
     e.printStackTrace(); 
    }//Exception 

最後請注意:第一個跳入編碼之前學習語言的語法。

+2

這完全是一個印刷錯誤;應該不是真正的問題。 – Makoto 2014-09-06 06:03:19

+0

@ ZachLecky檢查更新的答案。我強烈建議你花時間閱讀和學習java語法。 – 2014-09-06 06:08:57

相關問題