Online Course Discussion Forum

AP computer science A

 
 
ProfessorAreteem的头像
Re: AP computer science A
ProfessorAreteem - 2018年12月4日 Tuesday 23:07
 

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.