{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture7-Feb6-Interfaces2

Lecture7-Feb6-Interfaces2 - 1 1 162 COP 3503 SPRING 2012...

Info icon This preview shows pages 1–21. Sign up to view the full content.

View Full Document Right Arrow Icon
1 / 162 COP 3503 SPRING 2012 Shayan Javed Lecture 7 Programming Fundamentals using Java 1
Image of page 1

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

View Full Document Right Arrow Icon
2 / 162 More With Interfaces
Image of page 2
3 / 162 Interfaces Language construct for specifying functionality without implementation Method specifications but no implementations.
Image of page 3

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

View Full Document Right Arrow Icon
4 / 162 Interfaces in Software Engineering In large projects you have a lot of classes interacting with each other
Image of page 4
5 / 162 Interfaces in Software Engineering In large projects you have a lot of classes interacting with each other Need formal descriptions of what a class does, and how it interacts with other classes.
Image of page 5

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

View Full Document Right Arrow Icon
6 / 162 Interfaces in Software Engineering In large projects you have a lot of classes interacting with each other Need formal descriptions of what a class does, and how it interacts with other classes. Interfaces are a way to define expected behavior.
Image of page 6
7 / 162 Interfaces in Software Engineering In large projects you have a lot of classes interacting with each other Need formal descriptions of what a class does, and how it interacts with other classes. Interfaces are a way to define expected behavior. Useful when multiple teams working in
Image of page 7

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

View Full Document Right Arrow Icon
8 / 162 Interfaces Some interfaces already defined in Java Widely used Comparable Comparator Cloneable
Image of page 8
9 / 162 The Comparable interface Defined in the java.lang Package
Image of page 9

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

View Full Document Right Arrow Icon
10 / 162 The Comparable interface Defined in the java.lang Package public interface Comparable { public int compareTo(Object o); }
Image of page 10
11 / 162 The Comparable interface public interface Comparable { public int compareTo(Object o); }
Image of page 11

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

View Full Document Right Arrow Icon
12 / 162 The Comparable interface public interface Comparable { public int compareTo(Object o); } Comparisons between objects of the same type
Image of page 12
13 / 162 The Comparable interface public interface Comparable { public int compareTo(Object o); } Comparisons between objects of the same type Object1. compareTo (Object2)
Image of page 13

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

View Full Document Right Arrow Icon
14 / 162 The Comparable interface public interface Comparable { public int compareTo(Object o); } Comparisons between objects of the same type Object1. compareTo (Object2) Return values: < 0 = Object 1 < Object 2 (usually -1 )
Image of page 14
15 / 162 The Comparable interface public interface Comparable { public int compareTo(Object o); } Comparisons between objects of the same type Object1. compareTo (Object2) Return values: < 0 = Object 1 < Object 2 (usually -1 ) == 0 = Object 1 == Object 2
Image of page 15

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

View Full Document Right Arrow Icon
16 / 162 The Comparable interface public interface Comparable { public int compareTo(Object o); } Comparisons between objects of the same type Object1. compareTo (Object2) Return values: < 0 = Object 1 < Object 2 (usually -1 ) == 0 = Object 1 == Object 2 > 0 = Object 1 > Object 2 (usually 1 )
Image of page 16
17 / 162 The Comparable interface Used commonly.
Image of page 17

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

View Full Document Right Arrow Icon
18 / 162 The Comparable interface Used commonly. For ex. the String and Date classes.
Image of page 18
19 / 162 The Comparable interface public String implements Comparable,… { public int compareTo( Object o ) { // compares the two Strings lexicographically } }
Image of page 19

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

View Full Document Right Arrow Icon
20 / 162 The Comparable interface public String implements Comparable,… { public int compareTo( Object o ) { // compares the two Strings lexicographically } } Ex.: "computer". compareTo ("comparison")
Image of page 20
Image of page 21
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern