[所有分类]墨尔本大学java课程课件chap13.pptVIP

  • 0
  • 0
  • 约1.3万字
  • 约 35页
  • 2018-02-14 发布于浙江
  • 举报

[所有分类]墨尔本大学java课程课件chap13.ppt

[所有分类]墨尔本大学java课程课件chap13

* * * * * * * * * * * * * * * * * * GeneralizedSelectionSort class: sort Method 13-* Copyright ? 2010 Pearson Addison-Wesley. All rights reserved. GeneralizedSelectionSort class: interchange Method 13-* Copyright ? 2010 Pearson Addison-Wesley. All rights reserved. Sorting Arrays of Comparable 13-* Copyright ? 2010 Pearson Addison-Wesley. All rights reserved. Sorting Arrays of Comparable 13-* Copyright ? 2010 Pearson Addison-Wesley. All rights reserved. Sorting Arrays of Comparable 13-* Copyright ? 2010 Pearson Addison-Wesley. All rights reserved. Defined Constants in Interfaces An interface can contain defined constants in addition to or instead of method headings Any variables defined in an interface must be public, static, and final Because this is understood, Java allows these modifiers to be omitted Any class that implements the interface has access to these defined constants 13-* Copyright ? 2010 Pearson Addison-Wesley. All rights reserved. Pitfall: Inconsistent Interfaces In Java, a class can have only one base class This prevents any inconsistencies arising from different definitions having the same method heading In addition, a class may implement any number of interfaces Since interfaces do not have method bodies, the above problem cannot arise However, there are other types of inconsistencies that can arise 13-* Copyright ? 2010 Pearson Addison-Wesley. All rights reserved. Pitfall: Inconsistent Interfaces When a class implements two interfaces: One type of inconsistency will occur if the interfaces have constants with the same name, but with different values Another type of inconsistency will occur if the interfaces contain methods with the same name but different return types If a class definition implements two inconsistent interfaces, then that is an error, and the class definition is illegal 13-* Copyright ? 2010 Pearson Addison-Wesley. All rights reserved. The Serializable Interface An extreme but commonly used example of an interface is the Serial

文档评论(0)

1亿VIP精品文档

相关文档