Java的读线我是新来的Java世界, 我正在写一个简单的程序,但我有一个问题:与扫描仪
下面的代码:
while(choix!=7) {
System.out.println("Tapez un choix :") ;
choix=s.nextInt();
switch (choix) {
case 1 : { } break ;
case 2 :{
c.vider() ; }break ;
case 3 :{
int i,n; System.out.println("donnez le nombree de livres à ajouter");
n=s.nextInt();
for(i=0;i<n;i++) c.ajouter() ;
}break ;
case 4:{
c.Index() ;
c.affichagemotsvides();
c.affichageindex();
} break ;
case 5 :{
//s.wait();
String aut ;
System.out.println("Tapez le nom de l'auteur");
aut=s.nextLine() ; //Here's the line where i want to read the string
if (aut !=null)
System.out.println("==========>"+aut);
//livre l1 =new livre();
//l1=c.rechercheAut(aut);
//l1.afficher();
}break ;
第一次我输入一个数字choix=s.nextInt();
当我放5时,它正确地加速了。 aut=s.nextLine() ;
不要让我写我想输入的字符串。 下面是输出:
1. Créer un Catalogue
2. Vider le Catalogue
3. Ajouter des livres dans le Catalogue
4. Générer l’Index du Catalogue
5. Rechercher dans le Catalogue, par Auteur
6. Rechercher dans le Catalogue, par Mot Clé
7. Quitter
Tapez un choix :
5
Tapez le nom de l'auteur
==========>
Tapez un choix :