2016-04-03 16 views
-4

Bu kod ile ilgili sorun nedir? Uyguladığımda kontrol okumak için bekliyor. T çalıştırmak sayısı ve görüntülemek için bir for döngüsü içine configuration1 almak -Denetim dize nesnesini okumayı beklemiyor

public static void main(String[] args) { 
    int T,N; 
    String configurationl; 
    System.out.println("Enter the number of test cases."); 
    java.util.Scanner sc=new java.util.Scanner(System.in); 
    T=sc.nextInt(); 
    System.out.println("Enter the configuration"); 
    configurationl=sc.nextLine(); 
    System.out.println("The configuration is: "+ configurationl); 
} 
+0

burada kod olacak ?? –

+0

Kodlara bağlantı göndermeyin. StackOverflow, OP'nin yanı sıra _future_ okurlarına yardımcı olmayı amaçlamaktadır ve kötü giden linkler işe yaramaz hale getirir. Daha da kötüsü, bir IDE'ye kopyalanamayan/yapıştırılamayan _images_ koduna bağlantılar. –

+0

Geçen yılki yardımınız size yardımcı oldu mu Biswaranjan? Buraya yardım etmeye çalışan insanlara cevap vermek alışılmışın bir örneğidir. – halfer

cevap

1

İkinci giriş hattını koymak istiyorum.

public static void main(String[] args) { 
    int T, N; 
    System.out.println("Enter number of test cases: "); 
    Scanner in = new Scanner(System.in); 
    T = in.nextInt(); 

    String configuration1; 

    for (int i = 0; i < T; i++) { 
     System.out.println("Enter the configuration: "); 
     configuration1 = in.next(); 
     System.out.println("The configuration is: " + configuration1); 
    } 
} 

sonra çıkış

Enter number of test cases: 
3 
Enter the configuration: 
10 
The configuration is: 10 
Enter the configuration: 
20 
The configuration is: 20 
Enter the configuration: 
30 
The configuration is: 30 
İlgili konular