Click here to Skip to main content
15,669,039 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
import java.util.Scanner

public class InputExample {
   public static void main(String [] args) {
      Scanner scnr = new Scanner(;
      int userName = 0

What I have tried:

userNum = scnr.nextInt();
Updated 15-Nov-22 18:51pm

OK, you're going to have to post the entire code, not just the first part of it.

You're creating the input scanner and declaring the variable, then nothing. No closing braces, not getting input, not output of the value, ...

Just putting the two lines of code under "What I have tried" takes that code out of context and makes it meaningless. The two lines of code you put under that section prints the value, which will always be 0, and then gets an integer from input. Don't you think that's a bit backwards?
Share this answer
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900