Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

extract the int and char (beginner)

807598Sep 20 2006 — edited Sep 20 2006
Dear group,
Extract the integer value and cahr present in a given string. So I tried
the following:
import java.io.*;

public class p198
{

    public static void main (String[] args)
    {

        System.out.println("Type some text and press");
	int j;
 
        String string = "";
	
        InputStreamReader input = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(input);

        try
        {
            string = reader.readLine(); 

        }
        catch(Exception e){}
        
	try
	{
	   j = Integer.parseInt(string);
	    System.out. println(j);
	}catch(NumberFormatException e){}

    } 

}
I can only get through the half way. can any one guide me by giving some
key word to search the google for the above?
I am just started to learn java, thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 18 2006
Added on Sep 20 2006
1 comment
242 views