Results 1 to 2 of 2
- 12-04-2011, 07:04 PM #1
Member
- Join Date
- Dec 2011
- Posts
- 3
- Rep Power
- 0
Reading input and storing into array
I am having trouble doing so. I am required to have the user enter integers seperated by commas and I need to then store only the integers into an array. I am new to java. I tried the skip method but I don;t know how it works. Here is what I have so far. Thanks in advance!
int numbers;
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter your numbers separated by commas below:");
keyboard.skip(",");
numbers = keyboard.nextInt();
int arrayname[] = new int[numbers];
for (int i = 0; i < numbers; i++)
{
arrayname[i] = keyboard.nextInt();
}
- 12-04-2011, 08:08 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,609
- Rep Power
- 5
Similar Threads
-
Need help with array and storing input
By Bewitched1 in forum New To JavaReplies: 8Last Post: 07-24-2010, 05:16 PM -
Reading a txt file and then storing it in a 2d array
By blkshp1990 in forum New To JavaReplies: 2Last Post: 11-05-2009, 12:31 AM -
need help. problems storing and displaying multiple user input
By dDarko in forum New To JavaReplies: 3Last Post: 10-28-2009, 01:45 AM -
reading input from array and saving output to database md5 algorithm
By avinash4m in forum Advanced JavaReplies: 4Last Post: 03-12-2009, 11:25 AM -
Reading input file into an array
By littlefire in forum New To JavaReplies: 6Last Post: 10-18-2008, 11:51 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks