Hi, i'm new to java. I'm trying to read an integer and to print it.
Here is what i've done so far...
import java.io.IOException;
public class helloworld {
public static void main(String[] args) throws IOException {
int a = System.in.read();
System.out.println(a);
}
}
The problem is, that if for example i write 3 the console prints 51 ( its' ansi representation, i guess??)
I must write this
System.out.println( (char)a);
to make it work.
But, when I do this
import java.io.IOException;
public class helloworld {
public static void main(String[] args) throws IOException {
int a = 3;
System.out.println(a);
}
}
everything is printed right.
Could anyone tell me what's happening??