• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

for loop is not running properly

 
Siddhesh Desai
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12143
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic