助けてもらえますか?このJavaファイルをコンパイルしたときになぜこのエラーが発生するのか理解できません。エラーはトリッキーなもの(';' expected)
です。「;」テストアプリの「New」と「Rectangle」の間の7行目で期待されています。
メインのアプリコードが必要な場合は、それを追加することもできます。
import java.util.Scanner;
public class RectangleTest
{
public static void main( String[] args )
{
Scanner input = new Scanner( System.in );
Rectangle rectmeas = New Rectangle(); // LINE 7, WHERE THE ERROR IS
int userinput = getOptions();
while ( userinput != 3 )
{
switch ( userinput )
{
case 1:
System.out.print( "Please enter the length: " );
rectmeas.setLen( input.nextDouble() );
break;
case 2:
System.out.print( "Please enter the width: " );
rectmeas.setWid( input.nextDouble() );
break;
}
System.out.println( rectmeas.toString() );
userinput = getOptions();
}
}
private static int getOptions()
{
Scanner input = new Scanner( System.in );
System.out.println( "Press 1 to input the length" );
System.out.println( "Press 2 to input the width" );
System.out.print( "Which one?: " );
return input.nextInt();
}
}