Why can't I use a double to point to a place in an array?

Sorry if this is a stupid question, but whenever I compile code like this I get this error message:

QuickTest.java:16: possible loss of precision

found: double

required: int

System.out.println(s[t]);

I would use an int, but My array that I want to use in other code is 1000 places big. What am I doing wrong?

publicclass QuickTest{

static String[] s =new String[200];

publicstaticvoid main (String[] args){

s[0] ="Why";

s[1] ="do";

s[2] ="you";

s[3] ="own";

s[4] ="ten";

s[5] ="Red";

s[6] ="white";

s[7] ="and";

s[8] ="blue";

s[9] ="hats";

double t = 2;

System.out.println(s[t]);

}

}

[1346 byte] By [whofeelsthelove] at [2007-9-30 23:14:10]
# 1
you can't use a double because it could contain non-interger values, and that's not meaningful for an array index.An int can hold 2^32 numbers, so indexing over an array of 1000, or even 1000000 is no problem
armalcolm at 2007-7-7 13:46:41 > top of Java-index,Security,Event Handling...
# 2
If you don't care that double is not an integerSystem.out.println( (int) s[t]);
Peter-Lawrey at 2007-7-7 13:46:41 > top of Java-index,Security,Event Handling...
# 3
Thank should beSystem.out.println( s[(int) t] );
Peter-Lawrey at 2007-7-7 13:46:41 > top of Java-index,Security,Event Handling...
# 4
Another way to create this array is;String[] s = "Why do you own ten Red white and blue hats".split(" ");
Peter-Lawrey at 2007-7-7 13:46:41 > top of Java-index,Security,Event Handling...
# 5
I'm confused, I thought an int only went up to 255 (or something around that).
whofeelsthelove at 2007-7-7 13:46:41 > top of Java-index,Security,Event Handling...
# 6
> I'm confused, I thought an int only went up to 255 (or something around that).Confused, indeed. You thought wrong.You only need 8 bits to represent an unsigned 0-255. An int is 32 bits. Better go get a good Java book and read up.%
duffymo at 2007-7-7 13:46:41 > top of Java-index,Security,Event Handling...
# 7
heh, ok :p
whofeelsthelove at 2007-7-7 13:46:41 > top of Java-index,Security,Event Handling...
# 8
> I'm confused, I thought an int only went up to 255> (or something around that).If you talk about a byte you're closer to right.
uj_ at 2007-7-7 13:46:41 > top of Java-index,Security,Event Handling...