I have an abstract Java class with one (non-abstract) static method, e.g. like so:
So far, so good. This works. But now for the punchline: I would like to be able to have the function feep() able to throw an exception, but simply doing the following (changes highlighted) doesn't work:
This results in a compiler error non-static variable this cannot be referenced from a static context with a mark at the beginning of [red]new[/red].
Anyone know how to fix this?
Thanks in advance,
Alphons
Code:
public abstract class Foo
{
public abstract void bar();
public static void feep()
{
// actual code here
}
}
So far, so good. This works. But now for the punchline: I would like to be able to have the function feep() able to throw an exception, but simply doing the following (changes highlighted) doesn't work:
Code:
public abstract class Foo
{
public abstract void bar();
public static void feep() [b]throws SomeException[/b]
{
// actual code here
[b]if(something)
throw [red]new[/red] SomeException("whatever");[/b]
}
}
This results in a compiler error non-static variable this cannot be referenced from a static context with a mark at the beginning of [red]new[/red].
Anyone know how to fix this?
Thanks in advance,
Alphons