Skip to content

Instantly share code, notes, and snippets.

@neilghosh
Last active May 25, 2016 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilghosh/d788a29db2ca7ea95fd39483b278ad3d to your computer and use it in GitHub Desktop.
Save neilghosh/d788a29db2ca7ea95fd39483b278ad3d to your computer and use it in GitHub Desktop.
Read Command Line Numbers In Java
/*
* 1st line input - two numbers space separated
* 2nd line input - series (1st number of last line times) of number space separated
*/
import java.util.*;
import java.lang.*;
import java.io.*;
class ReadFromCommandLine {
public static void main (String[] args) {
Scanner scan = new Scanner(System.in);
int size = scan.nextInt();
int sum = scan.nextInt();
int[] a = new int[size];
scan.nextLine();
for(int i = 0; i < size ; i++) {
a[i] = scan.nextInt();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment