import java.util.*;
import java.util.Scanner;
public class InputconsoleArray2
{
public static void main(String args[]) throws java.io.IOException
{
int[] a=new int[100]; // create an array of type interger size
// Objects of type Scanner are useful for breaking down formatted input into tokens and
// translating individual tokens according to their data type
// By default, a scanner uses white space to separate tokens. (White space characters include blanks, tabs,
// and line terminators.
Scanner sc=new Scanner(System.in);
System.out.println("Please enter elements...");
int j=0;
//int next= sc.nextInt();
//System.out.println("Next = " + next);
while ( sc.hasNextInt())
{
a[j]=sc.nextInt();
System.out.println(" a[j] " + j +" " + a[j]);
j++;
}
sc.close();
int arrayCurrentSize = j--;
System.out.println("Array elements are : ");
for (int i=0; i< arrayCurrentSize; i++)
System.out.println(a[i]);
}
}
aomran 0 Newbie Poster
aomran 0 Newbie Poster
Diomedes 0 Newbie Poster
aomran 0 Newbie Poster
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
BestJewSinceJC 700 Posting Maven
aomran 0 Newbie Poster
BestJewSinceJC 700 Posting Maven
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
aomran 0 Newbie Poster
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.