how to take more than 1 console input

when i'm giving this code,it asks ntopics but then prints all the System.out.print() statements simultaneously and is asking for "no. of categories of this topic" i.e. ncatg directly without asking for maxcatg and topics.What is wrong with this code?

public static void main(String arg[])throws Exception

{

InputStreamReader isr=new InputStreamReader(System.in);

BufferedReader br = new BufferedReader(isr);

System.out.print("enter no. of topics");

int ntopics=System.in.read();

String topics[]=new String[ntopics];

System.out.println("enter maximum no. of categories among all topics");

int maxcatg=System.in.read();

String catg[][]=new String[ntopics][maxcatg];

int ncatg[]=new int[ntopics];

System.out.println("enter topics");

for(int i=1;i<=ntopics;i++)

{

System.out.println("enter topic " +i);

topics = br.readLine();

System.out.println("enter no. of categories of this topic");

ncatg=System.in.read();

System.out.println("enter name of categories");

for(int j=1;j<=ncatg;j++)

{

catg[j] = br.readLine();

}

if(ncatg<maxcatg)

{

for(int k=ncatg+1;k<=maxcatg;k++)

{

catg[k]="";

}

}

}

}>

[1381 byte] By [shwetaagrawala] at [2007-11-26 13:54:02]
# 1
The web-start forum to which you postedthis message is a very specialist forum.This question would be better suited to (the much higher traffic) forum shown here.. http://forum.java.sun.com/forum.jspa?forumID=54
AndrewThompson64a at 2007-7-8 1:32:25 > top of Java-index,Desktop,Deploying...