Import the Java. Util. HashMap;
Import the Java. Util. InputMismatchException;
import java.util.Map;
import java.util.Scanner;
The class Ranking
{
Public static void main (String [] args)
{
String [] teams={" Iran ", "South Korea", "Japan" and "Australia" and "Saudi Arabia", "uzbekistan", "the united Arab emirates, Qatar," Chinese ", "Syria"};
Mapmap=new HashMap (a);
For (int I=0; i{
The map. The put (I + 1, teams [I]);
}
System. The out. Println (map);
Scanner sc=new Scanner(System.in);
System. Out. Println (" according to input word query the full face one top 10 national men ");
Int number=sc. NextInt ();
Try {
If (number & gt; 0 & amp; & Number & lt;=10)
{
System. The out. Println (" afc ranking the first "+ number +" of the national men's "+ map. Get (number) +" ");
Sc. The close ();
} the else
{
System. Out.println (" input error! One can only enter 1-10 of integer ");
}
} the catch (InputMismatchException e)
{
System. The out. Println (" please enter the number ");
}
}
}
CodePudding user response:
Import the Java. Util. HashMap;Import the Java. Util. InputMismatchException;
import java.util.Map;
import java.util.Scanner;
The class Ranking
{
Public static void main (String [] args)
{
String [] teams={" Iran ", "South Korea", "Japan" and "Australia" and "Saudi Arabia", "uzbekistan", "the united Arab emirates, Qatar," Chinese ", "Syria"};
Map
For (int I=0; i
The map. The put (I + 1, teams [I]);
}
System. The out. Println (map);
Scanner sc=new Scanner(System.in);
System. Out. Println (" according to input word query the full face one top 10 national men ");
Int number=sc. NextInt ();
Try {
If (number & gt; 0 & amp; & Number & lt;=10)
{
System. The out. Println (" afc ranking the first "+ number +" of the national men's "+ map. Get (number) +" ");
Sc. The close ();
} the else
{
System. Out.println (" input error! One can only enter 1-10 of integer ");
}
} the catch (InputMismatchException e)
{
System. The out. Println (" please enter the number ");
}
}
}
CodePudding user response:
InputMismatchException anomaly refers to the values and setting the value of the input types do not match, such as you to set the integer, input the helloworld, the exception will be thrownCodePudding user response:
CodePudding user response:
The catch is that you try the local anomalies before execution, and you can have a try in the try to write a by zero is unusual, but need to catch in brackets into the Exception e should be followed to see the catchCodePudding user response:
To put int number=sc. NextInt (); includedCodePudding user response:
The words he would not return to please enter the number???????CodePudding user response: