how to take space separated input in java
String s[]= scanner.nextLine().split(" ");for(int i =0 ;i < s.length;i++){ a[i]= Integer.parseInt(s[i]);}
how to take space separated input in java
String s[]= scanner.nextLine().split(" ");for(int i =0 ;i < s.length;i++){ a[i]= Integer.parseInt(s[i]);}
how to read space separated integers in java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class BufferedReaderTest
{
public static void main(String[] args) throws IOException {
BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
int num[] = new int[1000];
String[] strNums;
long startTime, endTime;
/*________ TEST STARTS ________*/
startTime = System.nanoTime();
strNums = bi.readLine().split("\\s");
for(int i=0; i<strNums.length; i++) {
num[i] = Integer.parseInt(strNums[i]);
}
endTime = System.nanoTime();
/*________ TEST ENDS ________*/
System.out.println("Total Time Taken: " + (endTime - startTime));
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us