LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: venm11 on June 25, 2003, 15:17:09

Title: anyone know any good java coding forums?
Post by: venm11 on June 25, 2003, 15:17:09
I figured you guys might know of something.  I'm looking for web forums for java development on all kinds of topics - coding, apis, architecture, certifications and so forth.

Newsgroups and Sun JDC seem to have too many transients and too much noise... looking for something mid-sized with consistent, experienced people.

thanks folks.
Doug
Title: anyone know any good java coding forums?
Post by: princec on June 25, 2003, 18:31:49
A fair few of us in here are experienced and consistent. Go right ahead and use the forums!

There's also javagaming.org which has a better signal-to-noise ratio than the general Java forums in Sun but tends to be populated with newbies and unfortunates attempting to write games in Java2D etc etc. I frequent the place myself.


Cas :)
Title: anyone know any good java coding forums?
Post by: venm11 on June 25, 2003, 19:09:28
Allright.  :)  Let me ask my current question--

Why are you not allowed to override static methods when subclassing?  What's their rationale for this rule?
Title: anyone know any good java coding forums?
Post by: princec on June 25, 2003, 19:39:38
You can, but only using another static method.
The reason is that the statement:

obj.doSomething();

can not only refer to obj.doSomething() but also to MyObjectClass.doSomething() - you can imagine the fun and games if you were allowed to override a static doSomething() method with a nonstatic one.

So it's wisely disallowed.

Cas :)
Title: anyone know any good java coding forums?
Post by: venm11 on June 25, 2003, 22:19:30
I did an experiment and it does let you override a static method in a subclass;  it simply doesn't allow a name collision between static and instance methods, which is weird because their usage syntax isn't ambiguous; obj.doSomething() refers only to instance methods (and same for statics), right?

I guess the book people worded it incorrectly.
Title: anyone know any good java coding forums?
Post by: cfmdobbie on June 26, 2003, 01:08:31
Not quite - obj.doSomething() is a perfectly valid way of accessing a static method on the class that is the type of the obj reference.  Phew!

The thing about statics is that they're not resolved at runtime, but at compile time.  While you *can* override a static method, it doesn't work in the same way as an overridden instance method.  Consider the following:

public class Foo
{
public static String getName()
{
return "Foo" ;
}

public static void main(String[] args)
{
System.out.println(Foo.getName()) ; // "Foo"
System.out.println(Baa.getName()) ; // "Baa"

Foo f = new Foo() ;
System.out.println(f.getName()) ; // "Foo"

Baa b = new Baa() ;
System.out.println(b.getName()) ; // "Baa"

f = b ;
System.out.println(f.getName()) ; // "Foo"
}

static class Baa extends Foo
{
public static String getName()
{
return "Baa" ;
}
}
}


I've added the actual output as a comment against each print.  Most people don't expect that last result!  While the object being accessed was of type Baa, the reference used was of type Foo, so "Foo" was printed.

Nasty, eh? :D
Title: anyone know any good java coding forums?
Post by: princec on June 26, 2003, 11:01:43
Although I've just got to add that it's considered bad style to call a static method from an instance and it might even be made illegal in a future version of the JDK.

Cas :)
Title: anyone know any good java coding forums?
Post by: Mojomonkey on June 26, 2003, 13:05:46
Current compilers will even complain via warnings. Good example:


GL gl;
//...
gl.wglSwapIntervalEXT(1);


produces:

Quote
Warning         The static method wglSwapIntervalEXT(int) from the type GL should be accessed in a static way   jMonkeyEngine/jme/src/test/general/WaterRain.java   line 193
Title: anyone know any good java coding forums?
Post by: Virum on July 03, 2003, 17:31:52
www.digitaldesigners.org isn't a bad place.  We have a lots of good admins inlcuding *cough*me*cough*.  Anyway, we aren't swarming with newbie "do my homework for me" questions.............yet.  :)