About 65 results
Open links in new tab
  1. How to read integer value from the standard input in Java

    May 2, 2010 · Tests IOStream and basic bool modulo fxn.\n" + "Commented and coded for C/C++ programmers new to Java\n"); //create an object that reads integers: Scanner Cin = new …

  2. How to get the user input in Java? - Stack Overflow

    Mar 13, 2011 · Type 0 to exit. Enter an integer: 12 The number entered was: 12 Enter an integer: -56 The number entered was: -56 Enter an integer: 4.2 Invalid input type (must be an integer) …

  3. Java: how to read an input int - Stack Overflow

    Jan 10, 2013 · So, I was looking for an efficient way, using Java's standard packages, to read an input integer... For example, I came across the class "Scanner", but I found two main …

  4. parsing - taking integer input in java - Stack Overflow

    May 31, 2010 · java.util.Scanner is the best choice for this task.. From the documentation: For example, this code allows a user to read a number from System.in:

  5. java - How can I check if a value is of type Integer ... - Stack Overflow

    Sep 24, 2012 · To check if a String contains digit character which represent an integer, you can use Integer.parseInt(). To check if a double contains a value which can be an integer, you can …

  6. Validating input using java.util.Scanner - Stack Overflow

    what i have tried is that first i took the integer input and checked that whether its is negative or not if its negative then again take the input Scanner s=new Scanner(System.in); int a=s.nextInt(); …

  7. How to check the input is an integer or not in Java? [duplicate]

    Jul 26, 2017 · Yeah that seems a bit complicated. What you can read with the Scanner is a String. What @DarkKnight does right here, it's trying to convert the string into an integer (the parseInt …

  8. java - JOptionPane Input to int - Stack Overflow

    I am trying to make a JOptionPane get an input and assign it to an int but I am getting some problems with the variable types. I am trying something like this: Int ans = (Integer) JOptionPane.

  9. java - How to insist that a users input is an int? - Stack Overflow

    Oct 29, 2012 · Here's a simple example with prompts and comments. Scanner scan = new Scanner(System.in); System.out.print("Enter an integer: "); // Initial prompt for input // Repeat …

  10. java - How to use Scanner to accept only valid int as input - Stack ...

    not knowing what the kb object is, I'd read a String and then trying Integer.parseInt() and if you don't catch an exception then it's a number, if you do, read a new one, maybe by setting num2 …

Refresh