Hello,
I probably have a very simple question, but I can't really see to get it fixed. I am new to java and have to create some application. Now I want to read things from the console. I know how to do that. I first read an integer and then I walk that number of times through a loop.
Within that loop I read a second number and then I call another function which has to read text from the console. But I can't seem to get the reading in the second function to work. Any tips/help?
This is my current code:
Code:public class Main { private BufferedReader in public static String ReadInfo() { String strone; String strall; strall = ""; strone = in.readLine(); //Here is the problem, can I easily read info here? return strall; } public static void main(String[] args) { int iA; int iZ; String strG; BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); try { iA = Integer.parseInt(in.readLine()); for (int i = 0; i < iA; i++) { iZ = Integer.parseInt(in.readLine()); strG = ReadInfo(); }; } catch(java.io.IOException ioe) } }




Reply With Quote