I have a problem which reduces down to considering this class:
class myClass
{
static int s_int = getInteger();
static int getInteger() throws myClassException
{
...
Here's my problem: this will not compile since getInteger()
throws myClassException
and I don't have a try catch block when initialising s_int
.
One solution, of course, would be to build a getIntegerAndDealWithTheException()
which doesn't throw an exception and call that instead when initialising s_int. But I'd rather not as that is not so pretty: I'd rather not litter the code with stubs.
Am I missing a syntatic trick here with my initialisation of s_int?
Many thanks!