Discussion Locked

JAVA

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Helo all,

I am a beginner in Java.I can read a integer value from the terminal using the readline method in dataInputStream.(By type casting the String value to Integer!!)I tried out with System.in.read().But,it is giving the ASCII value..Can u
tell me an another way to do that????

Thanx in advance..

7 replies

by cedric king

u can add 64 to the number.
ie. if you read a value and place it in the variable, TempInt, then you can try
System.out.println("TempInt = " + (char)(TempInt + 64) + ".");

Hope this is what you want.

by crimsoncub

Instead of type casting you can create a new integer value from the string acquired using readLine():

int x = new Integer(STRING).intValue();

This discussion is closed to new replies.