Solved Checking if args only contains numbers.

Discussion in 'Spigot Plugin Development' started by ApplePie, Jun 29, 2016.

  1. Hello.
    I need to check if args[2] contains ONLY numbers.
    I am unsure of how to do this, and I would like it if someone could explain it to me?
    Thanks :)
     
  2. Code (Java):
    try {
         Integer.parseInt(args[2]);
    } catch (NumberFormatException ex) {
         // Isn't just numbers
    }
    Or if you want to allow decimal places, use Double.parseDouble
     
    • Agree Agree x 1
    • Winner Winner x 1
  3. Thanks a lot man :) This worked. I never knew you could do it like that..