Java "throws" on method, can't find symbol

Discussion in 'Java' started by eaglei22, Feb 19, 2012.

  1. eaglei22

    eaglei22 New Member

    Joined:
    Jan 27, 2012
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    In one class I do:
    public void setLeft(int left) throws BadException
    {
    if (left < 0 || left > 639)
    throw new BadException();
    else
    x1 = left;
    }

    then in another class I do:

    public static void main(String args[])
    {
    try
    {
    l1.setLeft(3000);
    }
    catch (BadException ex)
    {
    System.out.println("error message");
    ex.printStackTrace();
    }
    }


    I keep getting a cannot find symbol
    symbol : class BadException
    location: class Line
    public void setLeft(int left) throws BadException
    ^

    I can't figure it out.. What am I doing wrong???
     
  2. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28
    where do you declare class BadException ?
    is this class and your code in the same folder?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice