Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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));
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java convert char to charsequence 
Java :: meaning of instantiated in java 
Java :: set up a tree in java 
Java :: java binary tree 
Java :: how to set the length to int array in java 
Java :: create a string in java 
Java :: Java Create a BufferedReader 
Java :: encapsulation in java 
Java :: new int[] java 
Java :: Java Thread Example Using the Thread Class 
Java :: Java Create a PrintWriter 
Java :: java inheritance example 
Java :: calling static method in java 
Java :: java literals 
Java :: how to encrypt password in properties file in spring boot 
Java :: Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. 
Java :: save file to disk java 
Java :: java loop find index 
Java :: random class in java 
Java :: intelij show method information 
Java :: how to find poiwer in java 
Java :: how to make a messages config minecraft plugin 
Java :: java namespaces 
Java :: Java Default Access Modifier package one 
Java :: taking user input in array in java using constructor 
Java :: unique numbers in array java 
Java :: nonnull annotation in java 
Java :: konva crop outside width and height of image 
Java :: ternario java 
Java :: DMC5 performace mod 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =