I want to read an integer value from console, but my input returns the ASCII value of integer, Please Help me.

import java.io.*;

class Test{
	public static void main(String args[])throws IOException{
		BufferedInputStream br=new BufferedInputStream(System.in);
		System.out.println("Enter an Integer");
		int i=br.read();
		//int j=(int)i;


it's being read as a "char" so either cast it to an int, or read an "int" instead.

Here are a few examples on alternatives how to read Input from a Console :- 1,2,3.

Considering your case you might especially like the third link.

solution one pre Java 5:

BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

System.out.println("Enter an Integer");

String value = in.readLine();     // this line may throw IOException
int i = Integer.parseInt(value);

Solution two Java 5 and higher

import java.util.Scanner // import this class first

Scanner input = new Scanner(System.in);
System.out.println("Enter an Integer");
int i = input.nextInt();

make your pick

Both those options were already covered in my post.

If you don't want to answer the poor guys question then don't rather than posting links with little relevance to any of us

posting links with little relevance to any of us

Sorry to intrude, but what do you mean by that?


Sorry dude I confused your footnote for your actuall post.

@stephen84s sorry dude I confused your footnote for your actual post my bad.

I should probably look properly nextime

When you say: "little relevance to any of us".

But probably I misunderstood you, so never mind. Besides the OP already got enough help to solve his/her problem. Continuing this discussion might be meaningless.

Sorry if my attitude sound somehow aggressive.

A little misunderstanding there buddy. I see your avater is a pic of ghost in the shell; you into animies in any way.

Hola back