This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Read from character statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Read from character statement" Watch "Read from character statement" New topic

Read from character statement

Mohd Zaki Mohd Salikon

Joined: Dec 16, 2004
Posts: 27
Below is a subprogram. It shows the output with looping using integer keydata (while j==1).
1. How to convert the integer statement (1) to character statement ('Y')?
2. How to clearscreen the previous statement? In C language, we can insert clrscr(); with #include<conio.h>.

public static void main(String args[]) throws IOException
BufferedReader input = new BufferedReader
(new InputStreamReader(;

String input_jawap;
int j;
input_jawap = input.readLine();
j = Integer.parseInt(input_jawap);
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
1. How to convert the integer statement (1) to character statement ('Y')?

This is quite easy. First you need to understand what the Integer.parseInt method does. Look it up in the API docs and you will find it converts a certain type of variable into an int (look in the java.lang package).

Now you need to change your code so that instead of converting input_jawap into an int, you convert it into a character. If the Integer class is used to convert things into ints, which class might be used to convert things into characters?

You will also need to change the type of the 'j' variable too. After that you just need to make a small adjustment to the if statement so that it compares with a character instead of a number.
I agree. Here's the link:
subject: Read from character statement
It's not a secret anymore!