Example1Exception and Example1Method belong together in the same file. It would not make sense to put them in separate files.
public class Example1
{
public class Example1Exception extends Exception
{
public Example1Exception(String message)
{
super(message);
}
}
public static void Example1Method() throws Example1Exception
{
throw new Example1Exception("hello"); //error: non-static variable this cannot be referenced from a static context
}
}
How can I throw Example1Exception in Example1Method?