How to enter a string entered from the keyboard into an array?

args = new String[3]; Scanner sc = new Scanner(System.in); String from = sc.nextLine(); args[0] = "aaa"; args[1] = "bbbb"; args[2] = "00.00.2015"; 

    1 answer 1

    http://ideone.com/z9wBNL

     import java.io.*; class Ideone { public static void main (String[] args) throws java.lang.Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String[] a = new String[3]; String str; for (int q=0; q<a.length && (str=reader.readLine())!=null; ++q) { a[q] = str; } System.out.print(a[1]); } }