0

I'm an extreme beginner in java and programming world. The problem may appear dumb, but please help me. Every time I insert a number that is assigned to a variable, the number does not match, this is what happen: If I insert 1 = 49 2 = 50 3 = 51 4 = 52 5 = 53 6 = 54 7 = 55 8 = 56 9 = 57 However when I for example insert 35, it'll appear 53, because it just takes the first number (3). Thank you. Edit: This is the code: class Max {

public static void main(String args[]) throws IOException {
    int a;
     a = System.in.read();
    System.out.println("a is " + a); 
    }
}

That's what is printed: 1 // input a is 49

  • 3
    Your question does not include the detail required to answer it. Please include all your code (enclose it in 3 backticks, then it gets formatted nicely), as well as the errors you get (whether when compiling or running). If you get no errors, include what it prints, and what you wanted it to print. – rzwitserloot Sep 22 '20 at 12:27
  • To me this looks like your "1" is likely a character (ASCII: 49 decimal -> '1' character) and so on. But you should add your code to your question. – maloomeister Sep 22 '20 at 12:30
  • ok guys I put the code –  Sep 22 '20 at 12:40
  • 2
    [This answer](https://stackoverflow.com/a/34120618/11441011) explains your issue. Maybe you should use a [Scanner](https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html) instead. – maloomeister Sep 22 '20 at 12:42

0 Answers0