60 likes | 144 Views
CSE115: Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall 645-4739 alphonce@buffalo.edu. Agenda. Announcements Cell phones / laptops off & away / Name signs out Last time main method import directive java.lang package System.out.println
E N D
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall 645-4739 alphonce@buffalo.edu
Agenda • Announcements • Cell phones / laptops off & away / Name signs out • Last time • main method • import directive • java.lang package • System.out.println • Observer pattern for event handling • Today • @override • comments (// and /* */) • example code (see repo)
Announcements • Exam 2 • covers material from exam 1 up to & including today • review on Monday 10/22 • exam on Wednesday 10/24 • No recitations in exam week: 10/22 – 10/26
@Override • @Override is an annotation • The @Override annotation indicates that a method is defined to satisfy a specification given in a supertype. • Example: @Override public void actionPerformed(ActionEvent e) { … } • Without the @Override annotation the compiler will issue a warning; the compiler wants to know that the developer knows that a given method definition satisfies a requirement specified in a supertype, and that definition of the method was not accidentally the same as a supertype specification.
comments • Comments are parts of a source code file which are ignored by the compiler • Comments are used to document code for human readers • Java has two basic types of comments • in-line comments: anything from the characters ‘//’ (including these characters) to the end of a line is ignored as a comment private String _x; // _x holds a description of this object • block comments: anything between the characters ‘/*’ and the characters ‘*/’ (including these characters) is ignored as a comment /* The variable _x holds * a description of this * object. */ private String _x;
example code Check out the ‘SwingExamples’ project in the course’s code repository: • Host: timberlake.cse.buffalo.edu • Repository path: /projects/CSE115/Repositories/Fall2012/Student • Connection type: extssh