exception handling

public class Try{
import java.io.*;
    public static void main(String argv[]){
        Try t = new Try();
        t.go();
    }//End of main
public void go(){
     try{
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);
        br.readLine();
      } catch(Exception e){
     /*Not doing anything when exception occurs*/
     } //End of try
    System.out.println("Continuing");
   }//End of go
}

I was trying above example from link
http://www.jchq.net/certkey/0203certkey.htm
did not get any output.



I was trying to understand the output. Any links, ideas, resources,sample code highly appreciated. thanks in advance.
LVL 7
gudii9Asked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
It wait for input from stdin.
You won't get any output until you hit enter
0
 
for_yanCommented:
Maybe you ddn't get any output, as it was waiting for your input from keyboard?
0
 
for_yanCommented:

import java.io.*;

is normally on the very top not after class definition
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
for_yanCommented:




When I tyoes ttt it responed Contniuing...

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Try{

    public static void main(String argv[]){
        Try t = new Try();
        t.go();
    }//End of main
public void go(){
     try{
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);
        br.readLine();
      } catch(Exception e){
     /*Not doing anything when exception occurs*/
     } //End of try
    System.out.println("Continuing");
   }//End of go
}

Open in new window



ttt
Continuing

Open in new window

0
 
CEHJConnect With a Mentor Commented:
It prints "Continuing" after

a. you typed ttt
b. you then hit enter

as

>>System.out.println("Continuing");

is the last statement in the method called (go)
0
 
gudii9Author Commented:
>>>a. you typed ttt

just type ttt in eclipse console and then click enter right. please advise
0
 
objectsCommented:
> just type ttt in eclipse console and then click enter right. please advise

its irrelevant what you type, its just waiting for you to hit enter as I explained in my furst comment
0
 
for_yanConnect With a Mentor Commented:
Right.
It is btter to print a prompt like that
It would be much easier to interact with the program


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Try{

    public static void main(String argv[]){
        Try t = new Try();
        t.go();
    }//End of main
public void go(){
     try{
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);
  System.out.println("Enter line:);
        br.readLine();
      } catch(Exception e){
     /*Not doing anything when exception occurs*/
     } //End of try
    System.out.println("Continuing");
   }//End of go
}

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.