Hi there, I'm working on my assignment for uni and I'm having a few problems with one of the questions.
So I'm trying to set the class variable currentLeader to an object of the LongJumper class, it should be null on first run.
/*class variables */ private static LongJumper currentLeader;
then after the first jumper goes he should be set as the currentLeader, which I think I have under control but it's all coming unstuck when I try to use the private setter.
/** * A private class setter method for the class variable currentLeader */ private static void setCurrentLeader() { LongJumper.currentLeader = this; }
My compiler has told me "non-static variable this cannot be referenced from a static context."
I think know how to set it for an int, but setting it for an object has really thrown me
private static void incremenInt() { class.int = class.int + 1; }
I'd really appreciate if someone would be kind enough to offer me a few pointers on where I'm going wrong this, as I've pretty much run out of ideas and my course work doesn't seem to have included this type of scenario.
Thanks
edit. sorry if this is a little garbled I've been working on this for the past 6 hours