Results 1 to 4 of 4
Thread: Question about Keyboard input
- 12-17-2011, 01:27 PM #1
Member
- Join Date
- Dec 2011
- Posts
- 7
- Rep Power
- 0
Question about Keyboard input
public static void main(String args[])
{
Scanner keyIn = new Scanner(System.in);
double player1[], player2[], player3[], player4[], player5[], player6[], player7[], player8[], player9[], player10[] = new double [3];
System.out.print("Player 1: Enter 3 values --> ");
player1[0] = keyIn.nextDouble();
player1[1] = keyIn.nextDouble();
player1[2] = keyIn.nextDouble();
......
}
Hi guys,
new to Java, just doing a problem with keyboard input,
can someone explain why there's an error saying that player1 may not be initialized?
Thx!
- 12-17-2011, 02:21 PM #2
Senior Member
- Join Date
- Dec 2011
- Posts
- 102
- Rep Power
- 0
Re: Question about Keyboard input
it seems to me that u need to need to put into every string a "null".
I believe (correct me if I'm wrong ppl :| ) that it is because string isn't a primitive character. with int for example it should have worked fine.
try and write :
double player1[]=null, player2[]=null, player3[]=null, player4[]=null, player5[]=null, player6[]=null, player7[]=null, player8[]=null, player9[]=null, player10[]=null = new double [3];
- 12-17-2011, 02:33 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
Re: Question about Keyboard input
Last edited by Norm; 12-17-2011 at 03:38 PM. Reason: Moved the '10' outside of []s
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 12-17-2011, 04:33 PM #4
Member
- Join Date
- Dec 2011
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
Read input from keyboard
By bison in forum New To JavaReplies: 2Last Post: 11-20-2010, 06:48 PM -
How to use another image using a keyboard input
By Rekuta in forum New To JavaReplies: 0Last Post: 05-13-2010, 05:00 PM -
get keyboard input while running in the background?
By gen1mx6 in forum Advanced JavaReplies: 16Last Post: 07-16-2009, 03:51 PM -
Basic keyboard input and edit
By BHCluster in forum New To JavaReplies: 18Last Post: 08-08-2008, 11:52 PM -
Polled keyboard input through swing
By Prometheus in forum Advanced JavaReplies: 2Last Post: 02-04-2008, 04:05 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks