2

I got to code Java for an assignment where am I going wrong with this "if statement" surely if I enter anything but 10 in won't print out Variable information. Picture attached.

import java.util.Scanner;

public class JavaApplication7 {

  public static void main(String[] args) {

    Scanner input = new Scanner(System.in);
    int code = 0;
    code = input.nextInt();

    if (code == 10); {
      System.out.println(code);
    }
  }

}

If statement

Cœur
  • 34,719
  • 24
  • 185
  • 251
Ron Jeremy
  • 37
  • 6

1 Answers1

0

Never mind I think I figured it out I was ending my statement to early or something this stuff is not very forgiving. Edit: Just saw snr answered haha thank you.

Ron Jeremy
  • 37
  • 6
  • If my answer helps, you can click tick icon in my answer below number on the left side. – snr Aug 09 '18 at 01:25