Online Course Discussion Forum

AP computer science A

Picture of Areteem Professor
Re: AP computer science A
by Areteem Professor - Tuesday, December 4, 2018, 11:07 PM

This last one seems to work fine.

There are a few things to pay attention though.  The class name should start with a capital letter.  This is not required by syntax, but it's the conventional style.

Also make the indentations consistent.  Always indent by the same number of spaces (our textbook authors use 2 spaces; in the corporate world, 3 or 4 spaces is the most common.  Be consistent.

Keeping good style is a habit that you develop while you are learning.  Once it becomes a habit, you won't even realize that you are following the good guideline.  The modern IDEs such as Eclipse automatically does it for you, not just while you are typing, but also have a menu item to "beautify" your code for you.  When you are writing programs in big projects, your code can become cluttered over time and may be chaotic.  Using good style is always helpful, so it's better to develop this habit.