Basic Java (4) - COP 3330 Object-Oriented Programming...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 3330: Basic Java Page 1 © Dr. Mark Llewellyn COP 3330: Object-Oriented Programming Summer 2011 Basic Java Department of Electrical Engineering and Computer Science Computer Science Division University of Central Florida Instructor : Dr. Mark Llewellyn [email protected] HEC 236, 407-823-2790 http://www.cs.ucf.edu/courses/cop3330/sum2011
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
COP 3330: Basic Java Page 2 © Dr. Mark Llewellyn The Anatomy of a Java Program A Java application program contains the following basic components: Comments Reserved Words Modifiers Statements Blocks Classes Methods The main method (note: Java applets do not have a main method)
Background image of page 2
COP 3330: Basic Java Page 3 © Dr. Mark Llewellyn Java Comments Comments are designed to enhance the readability of source code. There are three styles of comments in Java: Line comments begin with // and consist of a single line only. Block comments begin with /* and end with */ and can cover many lines of commenting. Convention also puts an * in the leftmost position of every line in the comment. Javadoc comments begin with /** and end with */. They are used for documenting classes, data, and methods and can be extracted into an XHTML file using the JDK javadoc command. We’ll deal much more with this type of comment later.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
COP 3330: Basic Java Page 4 © Dr. Mark Llewellyn Java Comments A javadoc comment A block comment A line (in line) comment
Background image of page 4
COP 3330: Basic Java Page 5 © Dr. Mark Llewellyn Java File Layout Conventions Sun’s layout conventions for Java source files suggest that you include the following components in the order given: A block comment including the name of the file, the date, and any copyright information. An optional package declaration and any include statements. The public class or interface declaration. Any nonpublic class or interface declarations. Within each class declaration, the class components (comments, fields, constructors, and methods) should be laid out in the following order: A comment block containing class implementation details. These comments include any information that is not appropriate for javadoc comments, such as class invariants that are implementation specific. Static fields, ordered in decreasing accessibility (public fields first, the protected, package, and finally private). Instance fields, ordered similarly. Constructors. Methods, ordered by functionality.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
COP 3330: Basic Java Page 6 © Dr. Mark Llewellyn Reserved Words in Java Reserved words or keywords, are words that have a specific meaning to the compiler and cannot be uses for any other purposes in a Java program. Note that Java is a case-sensitive language, which means that while public is a reserved word Public is not. However, from a readability perspective, it is best to avoid a reserved word in any form except that for which it was intended. (Note: goto and const are C+ + reserved words not presently used in Java.) abstract
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 48

Basic Java (4) - COP 3330 Object-Oriented Programming...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online