read keyboard input and storing in an array?
- From: "guitarromantic@xxxxxxxxx" <guitarromantic@xxxxxxxxx>
- Date: 25 Nov 2005 09:10:54 -0800
Hey all,
New to this, so apologies for the presumably basic question:
I'm trying to store user input in an array, marks. Here's my [cut down]
code:
public class MarksDatabase
{
private int marks[];
public MarksDatabase(String moduleName) {
int[] marks = new int[200];
}
public static void readMarks() {
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter marks, then put -1 blah blah");
marks[] = keyboard.nextInt();
}
I get an error with the keyboard.nextInt part. I've probably
misunderstood my instructions, but can anybody explain to me where I'm
going wrong?
Matt
.
- Follow-Ups:
- Re: read keyboard input and storing in an array?
- From: Roedy Green
- Re: read keyboard input and storing in an array?
- From: Rhino
- Re: read keyboard input and storing in an array?
- Prev by Date: System.in.read() repeats its output at least twice!?
- Next by Date: Re: Importing data file into a Java Applet
- Previous by thread: System.in.read() repeats its output at least twice!?
- Next by thread: Re: read keyboard input and storing in an array?
- Index(es):
Relevant Pages
|
|