aspose file tools*
The moose likes Beginning Java and the fly likes for loop is not running properly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "for loop is not running properly" Watch "for loop is not running properly" New topic
Author

for loop is not running properly

Siddhesh Desai
Greenhorn

Joined: Jun 28, 2004
Posts: 9
import java.util.*;
import java.io.*;
class Array
{
public static void main(String args[])
throws IOException
{
//char p;
int array[]=new int[10];
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for(int i=0;i<5;i++)
{
array[i]=(int) br.read();

}

}
}


Program compiles but do not access array for given loop conditions
Ben Buchli
Ranch Hand

Joined: Mar 26, 2004
Posts: 83
I think your problem is that you use a class name that already exist in the the java standard library: Array.

I'm not sure on this, but it might be worth a try to rename your class.

hope that helps.

Ben
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

why do you think this is not working? what were you expecting to see, and what did you see?

i typed it in, compiled it, and ran it. everything seems fine to me.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: for loop is not running properly