• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Exception doubt

 
Ranch Hand
Posts: 481
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
class Q031 {
{
try
{
throw new Exception ( ) ;
}
catch ( IOException e )
{
System . out . println ( e ) ;
}
}
Q031 ( ) throws Exception{ }
public static void main ( String args [ ] ) throws Exception
{
System . out . println ( " GodSmack " );
}
}

Hi When i compiled the code .
I got
---------- Javac ----------
Q031.java:7: cannot resolve symbol
symbol : class IOException
location: class Q031
catch ( IOException e )
------------------------------------
Please explain me why
what should be done to avoid compilation error
 
Karu Raj
Ranch Hand
Posts: 481
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all sorry
i got output

You can make the code compile by handling the Exception in the initializer .

Any way give me some explaination
 
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
besides this, i think to use IOException in your code you need to add following line:
import java.io.;

Sandy
[ September 20, 2005: Message edited by: Sandeep Chhabra ]
reply
    Bookmark Topic Watch Topic
  • New Topic