On the style.jsp page, you imply (by example) that we should use curly braces like this: void foo() { while ( bar > 0 ) { System.out.println(); bar-- ; But in your applet code, you put the opening curly brace on the same line as the class declaration or the while statement. Are both ok?
We do not have the applet source code. It was lost. To work on the version 2 of the applet, we had to reverse compile the applet. The reverse compiler I used generated the brace placement "the right way".
Sorry, but I'm still confused. Is this right? ----------------------- void foo() { while ( bar > 0 ) { System.out.println(); ----------------------- Or is this right? ----------------------- void foo(){ while ( bar > 0 ) { System.out.println(); ----------------------- Or are both ok?
I think that when David said "your applet code", he meant one of the examlpes of code for applets in the Code Barn (or somewhere else?). When Paul read "applet code" he thought of the code for "the" applet at JavaRanch, the Rules Round-Up. So that's why these conversation fragments didnt' match up.
Just to clarify: both are OK. In fact: public void foobar() { is much more universally used. Look in almost any Java book and you will find the braces laid out that way.
Thanks, Jim. You're right that my confusion was caused by the fact that I did indeed mean one of the applet examples in the Code Barn, which used a different style from the one Paul has on the style.jsp page. As Thomas points out, I've seen curly braces used almost exclusively the way I saw it in the HelloAnimThreadFirst Applet code in the Code Barn: public void foobar() { My point wasn't to quibble about which way is best...but rather to learn which way or ways were "acceptable" at JavaRanch. I love the site so far (my second day) and plan to continue using it regularly to learn java. Thanks, DJ
I agree that it is confusing that all of the code in the Code Barn doesn't match what is stated in the Style Guide. We're working to correct that ASAP.
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
It means our mission is in jeapordy! Quick, read this tiny ad!
a bit of art, as a gift, the permaculture playing cards