Very simple Java question

July 28th, 2013

I wan’t to make a very simple program that says whether or not what you inputed is an interger or not.
This is the code:
import java.util.Scanner;
public class Apples {
   public static void main(String[] args) {
      Scanner Black = new Scanner(System.in);
      int Berry = (Black.nextInt());
      if (Black.nextInt() ){
         System.out.println("Black is an integer");
      }else if (Black.nextLine()){
         System.out.println("Black is not an integer");
      }
   }
}

I don’t know why it doesn’t work
(BTW: I’ve never ever programmed anything and this is one of my first things I want to try..)
Thnx in advance

Answer #1
You should look into Exceptions in Java. This is a hint for you, don’t want to spoon feed
Answer #2
thnx found it

 

| Sitemap |