M is a poor name for an array, and it should not use a capital letter.
So what goes wrong?
When writing a for loop, declare the loop index in the loop. Not before. You want it to go out of scope. Then use a different number as the array index when you print it out. I suspect that i will reach 5, and you can't have a no 5 element in that array.
ben istaharov wrote:all i want is an array to get 5 numbers
and then show then out.
If you want to print all the numbers in the array then you either have to have a loop that iterates over the array (like the one you have that fills the array) and in the body of the for loop print out the element at that index or you can just print the value returned by passing your array to the java.util.Arrays.toString() method.
But this isn't what you appeared to be asking in your first post where you mentioned only printing out 1's and 0's.
herer is the code.
that is the porblem:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Unhandled exception type IOException
lets start again please : i want a code line the allow you to enter numbers to array.
what is wrong with this?
ben istaharov wrote:what is wrong with this?
for (int i = 0 ; i < madrid.length; i++ )
madrid[i] = BasicIO.ReadInteger();
Assuming BasicIO.ReadInteger() returns an int or Integer there is nothing wrong with that code per se.
The error is complaining about an unhandled exception. I don't know the BasicIO class but I would guess its ReadInteger method is decalred to throw an IOException, which is a checked exception, whch means you either have to put the call to ReadInteger in a try/catch statement or declare the main method to throw an IOException.
There would have been a red mark against that line before you tried to run the code. If Eclipse gives you a red mark, believe it. Put your mouse on it, and it may help you sort it out.
ben istaharov wrote: . . . Exception in thread "main" java.lang.Error: Unresolved compilation problem: . . .