से हो रही इनपुट मैंstdin
3
10 20 30
की पहली संख्या दूसरी पंक्ति में संख्या की राशि है के लिए में stdin से इनपुट प्राप्त करना चाहते हैं। यहां मुझे जो मिला है, लेकिन यह लूप में फंस गया है ... इसलिए मुझे विश्वास है। मैं डीबग मोड में भाग गया और सरणी किसी भी मूल्य को असाइन नहीं कर रही है ...
import java.util.*;
public class Tester {
public static void main (String[] args)
{
int testNum;
int[] testCases;
Scanner in = new Scanner(System.in);
System.out.println("Enter test number");
testNum = in.nextInt();
testCases = new int[testNum];
int i = 0;
while(in.hasNextInt()) {
testCases[i] = in.nextInt();
i++;
}
for(Integer t : testCases) {
if(t != null)
System.out.println(t.toString());
}
}
}
धन्यवाद .. किसी कारण से यह लूप के साथ काम करता है; हालांकि यह थोड़ी देर के साथ काम नहीं करता है .. – miatech