View Single Post
  #7 (permalink)  
Old 12-11-2007, 06:13 PM
hey hey is offline
Member
 
Join Date: Dec 2007
Posts: 21
hey is on a distinguished road
Quote:
Originally Posted by staykovmarin View Post
Post your current code (also a partial exception is really of no help).

I have a feeling that InputInt is still static.
import java.util.Scanner;

class Input {
public int InputInt() {
int x = 0;
Scanner in = new Scanner(System.in);

// reads int from the console
// and stores into x
x = in.nextInt();

// notice that now you can close the stream, since the method is non static
in.close();

return x;
}

}
___________________

import java.util.Scanner;

class Input {
public int InputInt() {
int x = 0;
Scanner in = new Scanner(System.in);

// reads int from the console
// and stores into x
x = in.nextInt();

// notice that now you can close the stream, since the method is non static
in.close();

return x;
}

}



PS: how do you separate code from a message?
Reply With Quote