View Single Post
  #10 (permalink)  
Old 12-12-2007, 12:06 AM
staykovmarin staykovmarin is offline
Senior Member
 
Join Date: Nov 2007
Location: Newport, WA
Posts: 141
staykovmarin is on a distinguished road
Code:
import java.util.Scanner; class Min { public static void main(String[] args) { int x = 0, y = 0, z = 0, f = 0, i = 0; Input input = new Input(); x = input.InputInt(); System.out.println(x); y = input.InputInt(); System.out.println(y); input.close(); } } class Input { Scanner in; public int InputInt() { int x = 0; in = new Scanner(System.in); // reads int from the console // and stores into x x = in.nextInt(); return x; } public void close() { in.close(); } }
So after a little bit of reading, i found out that after you close a stream, it cant be reopened, even if you create a new one (although i swear that it worked fine when i did it :\ ) So here is another solution. Just close the stream after you are done getting the numbers.
Reply With Quote