sorry, c++ programmer new to java strikes again
i have this code
public class MainView extends View {
static final int DRAW_LIST_SIZE=100;
class EventDrawStuff {
int a;
int b;
int c;
}
static EventDrawStuff m_drawList[] = new EventDrawStuff[DRAW_LIST_SIZE];
class DrumEventDrawStuff {
int x;
int y;
}
static DrumEventDrawStuff m_eventDrawStuff = new DrumEventDrawStuff();
the declaration of m_drawList seems to work ok, the declaration of m_eventDrawStuff doesn’t compile. what’s the difference, can t just be that m_drawList is an array?
i notice that if i say
static DrumEventDrawStuff[] m_eventDrawStuff = new DrumEventDrawStuff[1];
that is ok but i don’t really want it to be an array of one, since its only a single thing.
i realise the way to fix the original code is to initialize m_eventDrawStuff in the constructor but that seem cumbersome and unnecessary.
perhaps i’ve got the wrong idea altogether, please enlighten me, thanks
You can do it in two way –
Make your inner class static
Create
DrumEventDrawStuffobject with the help ofMainViewobject.static DrumEventDrawStuff m_eventDrawStuff = new MainView().new DrumEventDrawStuff();