The lines of code inside a method start with a { and end with a }. By default Eclipse puts the starting curly bracket on the same line as the method name. And it puts the ending curly bracket directly underneath the "p" in public. See the example below
This is a great habit because you can easily find its matching starting curly bracket. Sometimes I will even add a comment after the ending curly bracket to indicate the method that it is ending. Plus most Java developers follow this convention, so it makes it much easier for other programmers to read your code.
Please follow this convention, even in your handwritten assignments. The AP exam is handwritten so you'll need to be able to write out legible code. Legible code makes it easier for the person reading and grading your AP exam.
public class Program {
public static void main(String[] args) {
sayGoodMorning();
} // end of main()
public static void sayGoodMorning() {
System.out.println("Guten morgen!");
System.out.println("Hello! My name is Jason!");
} // end of sayGoodMorning()
} // end of Program
No comments:
Post a Comment