Results 1 to 3 of 3
  1. #1
    Himanshu23 is offline Member
    Join Date
    Nov 2010
    Posts
    9
    Rep Power
    0

    Default Default imported packages

    As java.lang.* is default imported package.Yet, Exception need java.lang.Exception to be imported. Why?



    eg:


    import java.io.*;
    import java.lang.*;
    public class Main
    {
    public static void main(String args[])
    {
    BufferedReader br = new BufferedReader(new InputSteamReader(system.in));
    string name;
    try
    {
    name = br.readLine();
    }
    catch(Exception e)
    {
    System.out.println("exception is caught here.");
    }
    }
    }

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    :confused::confused:

    You dont have a import error here, you have other errors ;D


    Java Code:
    public class Main {
    	public static void main(String args[]) {
    		BufferedReader br = new BufferedReader(new InputSt[COLOR="Red"]r[/COLOR]eamReader([COLOR="Red"]S[/COLOR]ystem.in));
    		[COLOR="Red"]S[/COLOR]tring name;
    		try {
    			name = br.readLine();
    		} catch (Exception e) {
    			System.out.println("exception is caught here.");
    		}
    	}
    }

  3. #3
    Himanshu23 is offline Member
    Join Date
    Nov 2010
    Posts
    9
    Rep Power
    0

    Default

    I have tried that too
    But, without importing java.lang.*
    I'm unable to use catch(Exception e)

Similar Threads

  1. how can downloaded package be imported in java
    By aldm in forum New To Java
    Replies: 3
    Last Post: 10-08-2010, 10:16 AM
  2. show the comment in the imported class
    By javastuden in forum New To Java
    Replies: 5
    Last Post: 08-31-2010, 10:37 AM
  3. Is the imported package foo beeing used in the programm
    By cthulhufhtagn in forum New To Java
    Replies: 3
    Last Post: 11-01-2009, 04:27 PM
  4. Replies: 1
    Last Post: 03-10-2009, 01:12 PM
  5. Replies: 3
    Last Post: 02-12-2008, 11:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •