0

this is my code:

public static void main(String[] args) {
    System.out.println("Insert number:");
    int read = creaScanner().nextInt();
    System.out.println("I read "+read);
}

private static Scanner creaScanner() {
    Scanner s = new Scanner(System.in);
    s.useDelimiter(System.getProperty("line.separator"));
    return s;
}

When i run it and type an int and hit enter it just takes me to the next line and displays nothing. Without the line

s.useDelimiter(System.getProperty("line.separator"));

everything works just fine, but this code worked on Eclipse, so i wanted to know if i have to change some settings to make it work on Intellij.

Thanks you in advance

PS

My question is different from this one ( How do I use a delimiter in Java Scanner? ) because i already know how to use scanner and this code runs correctly in Eclipse, but not in intellij. So i was wondering if there's some settings to change to make it work also on intellij. (I am not allowed to change that part of the code, so the answer i am looking for is probably about an intellij setting).

Community
  • 1
  • 1
Marco Cadei
  • 135
  • 2
  • 4
  • 14

0 Answers0