Java 5 New Language Features
|
|
- Amie Kelley
- 6 years ago
- Views:
Transcription
1 Java 5 New Language Features Ing. Jeroen Boydens, BLIN prof dr. ir. Eric Steegmans Enterprise Programming Last session. Jeroen Boydens 1. JDK v1.4: assert 2. Generics 3. Autoboxing/unboxing 4. Covariant Overriding 5. Enhanced for loop 6. Typesafe enums 7. Varargs 8. import static APT: Annotation Processing Tool (in the small) 2 EP research 1
2 This Session. Eric Steegmans 1. Definition 2. Instantiation 3. Compilation 4. Raw Types 5. Polymorphism 6. Wildcards 7. Bounded Wildcards 8. Subclassing 9. Generic Methods Generics (in the large) 3 Generic Classes Generic classes or generic interfaces have one or more type parameters Formal type parameters can only be bound to reference types, not to primitive types Formal type parameters can be used (almost) everywhere a type can be used public class GenericClass<S,T> { public S somemethod(t p) { S localvar; 4 EP research 2
3 Definition Formal type parameters can not be used to create objects of formal parameter type create arrays of formal parameter type public class GenericClass<S,T> { public void somemethod() { // Illegal statements. new S( ); new S[10]; 5 Instantiation Supply actual reference types for formal arguments An actual argument may in turn be an instantiated generic class GenericClass<Integer,Person> myvariable = new GenericClass<Integer,Person>( ); ArrayList<Integer> mylist = new ArrayList<Integer>(); ArrayList<ArrayList<Integer>> mysuperlist = new ArrayList<ArrayList<Integer>>(); 6 EP research 3
4 Instantiation The Java compiler can now perform checks that had to be done at run-time otherwise Actual arguments must have the proper type Lots of type casts are avoided ArrayList<Integer> mylist = new ArrayList<Integer>(); //Arguments for method add when applied to mylist must have //static type Integer! mylist.add(27); //Type cast needed here in non-generic code! Integer myresult = mylist.get(2); 7 Compilation A generic class is compiled once and for all, resulting in a single class file All objects of instantiations of a generic class belong to the same class The class underlying all instantiations of a generic class is called a raw type For reasons of backward compatibility, raw types may still be used in programs Sun deprecates their usage in new code 8 EP research 4
5 Raw Types // The raw type for GenericClass public class GenericClass { public Object somemethod(object p) { Object localvar; // Declaration of a variable of raw type. GenericClass myrawobject = ; 9 Polymorphism Instantiations of a generic class never have a subtype/supertype relation This is true even if the one actual type is a subclass of the other actual type Integer is a subtype of Number; ArrayList<Integer> is not a subtype of ArrayList<Number> Strange enough, this rule does not apply to built-in in arrays Arrays of type Integer[] are thus assignable to variables of type Number[] 10 EP research 5
6 Wildcards Java offers wildcards to approach generic objects in a polymorphic way The most general wildcard stands for any type, and is denoted? ArrayList<?> is the supertype of all instantiations of the generic class ArrayList 11 Wildcards Methods with formal generic arguments against variables of wildcard-type Given ArrayList<?> mylist, mylist.add(new Integer()) is invalid Methods with formal generic return type against variables of wildcard-type Given ArrayList<?> mylist, Object o = mylist.get(0) is valid 12 EP research 6
7 Bounded Wildcards Bounded wildcards are wildcards with an upper bound or a lower bound A wildcard with upper bound T stands for type T or any sybtype of T A bounded wild card with upper bound T is denoted "? extends T " ArrayList<? extends Number> is the supertype of all instantiations of ArrayList involving Number or a subclass of Number 13 Bounded Wildcards A wildcard with lower bound lower bound T stands for type T or any supertype of T A bounded wild card with lower bound T is denoted "? super T " ArrayList<? super Number> is the supertype of all instantiations of ArrayList involving Number or a superclass of Number Restrictions that apply to unrestricted wildcards equally apply to bounded wildcards 14 EP research 7
8 Subclassing A generic type can be defined to inherit from another generic type The generic subclass actually inherits from an instantiation of its generic superclass A generic type can also inherit from an ordinary class or to implement an ordinary interface public class GenericSubClass<S,T> extends GenericSuperclass<S> implements GenericInterface<T>, Cloneable { { 15 Subclassing Formal type arguments may use upper bounded wildcards The raw type then includes type casts related to that upper bound public class GenericSubClass<S extends Number,T> extends GenericSuperclass<S> implements GenericInterface<T> { 16 EP research 8
9 Generic Methods A generic method is parameterized in one or more types Generic arguments express dependencies among types of formal arguments involved in a method Bounded wildcards in both directions are used for that purpose public <T> void genericmethod(collection<t> coll) { public static <T> void genericmethod (Collection<T> coll, Iterator<? super T>) { 17 Generic Methods The actual types of a generic method are derived from the actual arguments The compiler rejects invocations if no matching type is available 18 EP research 9
Java Brand Generics. Advanced Topics in Java. Khalid Azim Mughal Version date:
Java Brand Generics Advanced Topics in Java Khalid Azim Mughal khalid@ii.uib.no http://www.ii.uib.no/~khalid/atij/ Version date: 2005-03-03 Khalid Azim Mughal Java Brand Generics 1/40 Overview Introduction
More informationCore Java - SCJP. Q2Technologies, Rajajinagar. Course content
Core Java - SCJP Course content NOTE: For exam objectives refer to the SCJP 1.6 objectives. 1. Declarations and Access Control Java Refresher Identifiers & JavaBeans Legal Identifiers. Sun's Java Code
More informationExercise 8 Parametric polymorphism November 18, 2016
Concepts of Object-Oriented Programming AS 2016 Exercise 8 Parametric polymorphism November 18, 2016 Task 1 Consider the following Scala classes: class A class B extends A class P1[+T] class P2[T
More informationGeneralized Code. Fall 2011 (Honors) 2
CMSC 202H Generics Generalized Code One goal of OOP is to provide the ability to write reusable, generalized code. Polymorphic code using base classes is general, but restricted to a single class hierarchy
More informationJava: exceptions and genericity
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: exceptions and genericity Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Exceptions Exceptions
More informationInheritance and object compatibility
Inheritance and object compatibility Object type compatibility An instance of a subclass can be used instead of an instance of the superclass, but not the other way around Examples: reference/pointer can
More informationParametric polymorphism and Generics
Parametric polymorphism and Generics Today s Lecture Outline Parametric polymorphism Java generics Declaring and instantiating generics Bounded types: restricting instantiations Generics and subtyping.
More informationLecture Outline. Parametric Polymorphism and Java Generics. Polymorphism. Polymorphism
Lecture Outline Parametric Polymorphism and Java Generics Parametric polymorphism Java generics Declaring and instantiating generics Bounded types: restricting instantiations Generics and subtyping. Wildcards
More informationJava for Programmers Course (equivalent to SL 275) 36 Contact Hours
Java for Programmers Course (equivalent to SL 275) 36 Contact Hours Course Overview This course teaches programmers the skills necessary to create Java programming system applications and satisfies the
More informationCS61B Lecture #24. Today: Java support for generic programming. Readings for today: A Java Reference, Chapter 10.
CS61B Lecture #24 Today: Java support for generic programming Readings for today: A Java Reference, Chapter 10. Readings for Monday: Data Structures, 6.4. Last modified: Fri Oct 19 19:33:03 2012 CS61B:
More informationFast Track to Core Java 8 Programming for OO Developers (TT2101-J8) Day(s): 3. Course Code: GK1965. Overview
Fast Track to Core Java 8 Programming for OO Developers (TT2101-J8) Day(s): 3 Course Code: GK1965 Overview Java 8 Essentials for OO Developers is a three-day, fast-paced, quick start to Java 8 training
More informationPractice for Chapter 11
Practice for Chapter 11 MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) Object-oriented programming allows you to derive new classes from existing
More informationContents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix
PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring
More informationGenerics method and class definitions which involve type parameters.
Contents Topic 07 - Generic Programming I. Introduction Example 1 User defined Generic Method: printtwice(t x) Example 2 User defined Generic Class: Pair Example 3 using java.util.arraylist II. Type
More informationCMSC 132: Object-Oriented Programming II. Generic Programming. Department of Computer Science University of Maryland, College Park
CMSC 132: Object-Oriented Programming II Generic Programming Department of Computer Science University of Maryland, College Park Generic Programming Generic programming Defining constructs that can be
More informationGraphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java
More informationPARAMETRIC POLYMORPHISM
PARAMETRIC POLYMORPHISM Java C#! Parametric polymorphism: " Java Generics and Generic C# for.net! The idea: the compiler is able to check parametric classes just looking at their definilon 1 Java Generics
More informationRules and syntax for inheritance. The boring stuff
Rules and syntax for inheritance The boring stuff The compiler adds a call to super() Unless you explicitly call the constructor of the superclass, using super(), the compiler will add such a call for
More informationGeneric types. Announcements. Raw ArrayLists. Generic types (cont.) Creating a raw ArrayList: Accessing a raw ArrayList:
Announcements PS 3 is ready Midterm exam 1: Tuesday, April 11, in class Closed book but one sheet, both sides, of A4 paper is allowed Today s topic: Generics (parameterized types) Readings for this slide
More informationClosed book but one sheet, both sides, of A4 paper is allowed. Section 2.5 of the text Generics in the Java Programming Languages by Gilad Bracha
Announcements PS 3 is ready Midterm exam 1: Tuesday, April 11, in class Closed book but one sheet, both sides, of A4 paper is allowed Today s topic: Generics (parameterized types) Readings for this slide
More informationThe collections interfaces
Generics in Java Advanced Programming 4/18/16 1 The collections interfaces Contains unique elements Maps unique keys to values 4/18/16 2 Collections in Java Array has a special language support Iterators
More informationCS61B Lecture #23. Today: Java support for generic programming. Readings for today: A Java Reference, Chapter 10.
CS61B Lecture #23 Announcements: Josh s office hours are now back in his office. HW6 now due Saturday. Partial solar eclipse tomorrow, starting at 1:52PM. Next one in August, 2017. See http://www.timeanddate.com/eclipse/list.html
More informationThe Java Programming Language
The Java Programming Language Slide by John Mitchell (http://www.stanford.edu/class/cs242/slides/) Outline Language Overview History and design goals Classes and Inheritance Object features Encapsulation
More informationContents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance
Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass
More informationCSE 331 Software Design and Implementation. Lecture 14 Generics 2
CSE 331 Software Design and Implementation Lecture 14 Generics 2 Zach Tatlock / Spring 2018 Big picture Last time: Generics intro Subtyping and Generics Using bounds for more flexible subtyping Using wildcards
More informationJava 8 Programming for OO Experienced Developers
www.peaklearningllc.com Java 8 Programming for OO Experienced Developers (5 Days) This course is geared for developers who have prior working knowledge of object-oriented programming languages such as
More informationAgenda. Objects and classes Encapsulation and information hiding Documentation Packages
Preliminaries II 1 Agenda Objects and classes Encapsulation and information hiding Documentation Packages Inheritance Polymorphism Implementation of inheritance in Java Abstract classes Interfaces Generics
More informationObject Oriented Programming: Based on slides from Skrien Chapter 2
Object Oriented Programming: A Review Based on slides from Skrien Chapter 2 Object-Oriented Programming (OOP) Solution expressed as a set of communicating objects An object encapsulates the behavior and
More informationSTUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes
STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes Java Curriculum for AP Computer Science, Student Lesson A20 1 STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes INTRODUCTION:
More informationGenerics and Type Safety. CS 180 Sunil Prabhakar Department of Computer Science Purdue University
Generics and Type Safety CS 180 Sunil Prabhakar Department of Computer Science Purdue University Dynamic Data Collections Already seen several examples of dynamic data Linked list, Stack, Queue, Trees
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationCS61B Lecture #25: Java Generics. Last modified: Thu Oct 18 21:04: CS61B: Lecture #25 1
CS61B Lecture #25: Java Generics Last modified: Thu Oct 18 21:04:53 2018 CS61B: Lecture #25 1 The Old Days Java library types such as List didn t used to be parameterized. All Lists were lists of Objects.
More informationCSE 331. Generics (Parametric Polymorphism)
CSE 331 Generics (Parametric Polymorphism) slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/ 1 Parametric polymorphism
More informationIntroduction to Generics. Defining a Class with a Type Parameter
Introduction to Generics Beginning with version 5.0, Java allows class and method definitions that include parameters for types Such definitions are called generics Generic programming with a type parameter
More informationCSE 331 Software Design and Implementation. Lecture 14 Generics 2
CSE 331 Software Design and Implementation Lecture 14 Generics 2 James Wilcox / Winter 2016 Hi, I m James! Big picture Last time: Generics intro Subtyping and Generics Using bounds for more flexible subtyping
More informationPolymorphism. CMSC 330: Organization of Programming Languages. Two Kinds of Polymorphism. Polymorphism Overview. Polymorphism
CMSC 330: Organization of Programming Languages Polymorphism Polymorphism Definition Feature that allows values of different data types to be handled using a uniform interface Applicable to Functions Ø
More informationGenerics with Type Bounds
Generics with Type Bounds Computer Science and Engineering College of Engineering The Ohio State University Lecture 27 Generic Methods Like classes, methods can be generic class ArrayOps { //ordinary nongeneric
More informationinterface MyAnno interface str( ) val( )
Unit 4 Annotations: basics of annotation-the Annotated element Interface. Using Default Values, Marker Annotations. Single-Member Annotations. The Built-In Annotations-Some Restrictions. 1 annotation Since
More informationJava 1.5 in a Nutshell
Java 1.5 in a Nutshell Including Generics, Enumerated Types, Autoboxing/Unboxing, and an Enhanced for Loop http://java.sun.com/j2se/1.5.0/docs/guide/language/ CS 2334 University of Oklahoma Brian F. Veale
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
More informationCSE Lecture 7: Polymorphism and generics 16 September Nate Nystrom UTA
CSE 3302 Lecture 7: Polymorphism and generics 16 September 2010 Nate Nystrom UTA 2 Polymorphism poly = many morph = shape Allow a variable to contain values with different types 3 Subtype polymorphism
More informationChapter 5: Procedural abstraction. Function procedures. Function procedures. Proper procedures and function procedures
Chapter 5: Procedural abstraction Proper procedures and function procedures Abstraction in programming enables distinction: What a program unit does How a program unit works This enables separation of
More informationJava: introduction to object-oriented features
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer
More informationA Short Summary of Javali
A Short Summary of Javali October 15, 2015 1 Introduction Javali is a simple language based on ideas found in languages like C++ or Java. Its purpose is to serve as the source language for a simple compiler
More informationGenerics עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון
Generics עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון 2 Example List myintlist = new LinkedList(); // 1 myintlist.add(new Integer(0)); // 2 Integer x = (Integer) myintlist.iterator().next(); // 3
More informationModule 11. Collections and Iterators. Adapted from Absolute Java, Rose Williams, Binghamton University
Module 11 Collections and Iterators Adapted from Absolute Java, Rose Williams, Binghamton University Parameterized Classes and Generics Beginning with version 5.0, Java allows class and method definitions
More informationChapter 14 Abstract Classes and Interfaces
Chapter 14 Abstract Classes and Interfaces 1 What is abstract class? Abstract class is just like other class, but it marks with abstract keyword. In abstract class, methods that we want to be overridden
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationCOMP1008 An overview of Polymorphism, Types, Interfaces and Generics
COMP1008 An overview of Polymorphism, Types, Interfaces and Generics Being Object-Oriented Exploiting the combination of: objects classes encapsulation inheritance dynamic binding polymorphism pluggability
More informationCSE 331 Software Design & Implementation
CSE 331 Software Design & Implementation Hal Perkins Autumn 2013 Generics (Polymorphism) (Slides by Mike Ernst and David Notkin) 1 Varieties of abstraction Abstraction over computation: procedures int
More informationCS61B Lecture #25: Java Generics. Last modified: Thu Oct 19 19:36: CS61B: Lecture #25 1
CS61B Lecture #25: Java Generics Last modified: Thu Oct 19 19:36:29 2017 CS61B: Lecture #25 1 The Old Days Java library types such as List didn t used to be parameterized. All Lists were lists of Objects.
More informationGenerics עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון
Generics עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון 2 Example List myintlist = new LinkedList(); // 1 myintlist.add(new Integer(0)); // 2 Integer x = myintlist.iterator().next(); // 3 3 Example
More informationLogistics. Final Exam on Friday at 3pm in CHEM 102
Java Review Logistics Final Exam on Friday at 3pm in CHEM 102 What is a class? A class is primarily a description of objects, or instances, of that class A class contains one or more constructors to create
More informationOVERRIDING. 7/11/2015 Budditha Hettige 82
OVERRIDING 7/11/2015 (budditha@yahoo.com) 82 What is Overriding Is a language feature Allows a subclass or child class to provide a specific implementation of a method that is already provided by one of
More informationAnnouncements. Lecture 15 Generics 2. Announcements. Big picture. CSE 331 Software Design and Implementation
CSE 331 Software Design and Implementation Lecture 15 Generics 2 Announcements Leah Perlmutter / Summer 2018 Announcements Quiz 5 is due tomorrow Homework 6 due tomorrow Section tomorrow! Subtyping now
More informationCSE 331 Software Design and Implementation. Lecture 15 Generics 2
CSE 331 Software Design and Implementation Lecture 15 Generics 2 Leah Perlmutter / Summer 2018 Announcements Announcements Quiz 5 is due tomorrow Homework 6 due tomorrow Section tomorrow! Subtyping now
More information1.1. Annotations History Lesson - C/C++
1. Additions Thanks to Dr. James Heliotis. He started it all :) See also here: and see also here: and here: You need to use the tools from the Java release candidate 1 % bash % export PATH=/usr/local/j2sdk1.5.0-rc1/bin:$PATH
More informationWhat is Inheritance?
Inheritance 1 Agenda What is and Why Inheritance? How to derive a sub-class? Object class Constructor calling chain super keyword Overriding methods (most important) Hiding methods Hiding fields Type casting
More informationJava Generics -- an introduction. Based on https://docs.oracle.com/javase/tutorial/java/generics/why.html
Java Generics -- an introduction Based on https://docs.oracle.com/javase/tutorial/java/generics/why.html Generics vs. Templates Templates in C++ are compiled into unique code based on the types passed
More informationObject-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)
Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci) Sung Hee Park Department of Mathematics and Computer Science Virginia State University September 18, 2012 The Object-Oriented Paradigm
More informationPieter van den Hombergh Richard van den Ham. March 1, 2018
,, Pieter van den Hombergh Richard van den Ham Fontys Hogeschool voor Techniek en Logistiek Type : Upper March 1, 2018 /FHTenL, March 1, 2018 1/29 Topics, Type : Upper Type : Lower Bounds, accepting things
More informationINHERITANCE & POLYMORPHISM. INTRODUCTION IB DP Computer science Standard Level ICS3U. INTRODUCTION IB DP Computer science Standard Level ICS3U
C A N A D I A N I N T E R N A T I O N A L S C H O O L O F H O N G K O N G INHERITANCE & POLYMORPHISM P2 LESSON 12 P2 LESSON 12.1 INTRODUCTION inheritance: OOP allows a programmer to define new classes
More information1. Every program must have at least one class declaration. (*) 2. Every class declared in a program must have a distinct identifier.
The J- Language (Static) Semantics Version 1.3 (4/5/07) We define here the syntactic restrictions and static semantics of the simple language J- used in 2006 for 3516ICT assignments. Most of these restrictions
More informationCS 251 Intermediate Programming Inheritance
CS 251 Intermediate Programming Inheritance Brooke Chenoweth University of New Mexico Spring 2018 Inheritance We don t inherit the earth from our parents, We only borrow it from our children. What is inheritance?
More informationCollections Algorithms
Collections Algorithms 1 / 11 The Collections Framework A collection is an object that represents a group of objects. The collections framework allows different kinds of collections to be dealt with in
More informationCONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17
List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code
More informationSyllabus & Curriculum for Certificate Course in Java. CALL: , for Queries
1 CONTENTS 1. Introduction to Java 2. Holding Data 3. Controllin g the f l o w 4. Object Oriented Programming Concepts 5. Inheritance & Packaging 6. Handling Error/Exceptions 7. Handling Strings 8. Threads
More information09/02/2013 TYPE CHECKING AND CASTING. Lecture 5 CS2110 Spring 2013
1 TYPE CHECKING AND CASTING Lecture 5 CS2110 Spring 2013 1 Type Checking 2 Java compiler checks to see if your code is legal Today: Explore how this works What is Java doing? Why What will Java do if it
More informationZhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson
Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program
More informationSelf-review Questions
7Class Relationships 106 Chapter 7: Class Relationships Self-review Questions 7.1 How is association between classes implemented? An association between two classes is realized as a link between instance
More informationUniverse Type System for Eiffel. Annetta Schaad
Universe Type System for Eiffel Annetta Schaad Semester Project Report Software Component Technology Group Department of Computer Science ETH Zurich http://sct.inf.ethz.ch/ SS 2006 Supervised by: Dipl.-Ing.
More informationDistributed Systems Recitation 1. Tamim Jabban
15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Tuesday: 9:30-11:59 AM Thursday: 10:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming
More informationIntroducing Generics
Generics Introducing Generics Generics allow reference types (classes, interfaces, and array types) and methods to be parameterized with type information. An abstract data type (ADT) defines both the types
More information#Students per correct answers
Generics in Java Programming Projects 14/04/15 1 #Students per correct answers Quiz"2" 10" 9" 8" 7" 6" 5" 4" 3" 2" 1" 0" 10" 9" 8" 7" 6" 5" 4" 3" 2" 1" 0" #"Correct"Answers" 10" 9" 8" 7" 6" 5" 4" 3" 2"
More informationJava Inheritance. Written by John Bell for CS 342, Spring Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources.
Java Inheritance Written by John Bell for CS 342, Spring 2018 Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources. Review Which of the following is true? A. Java classes may either
More informationBinghamton University. CS-140 Fall Dynamic Types
Dynamic Types 1 Assignment to a subtype If public Duck extends Bird { Then, you may code:. } Bird bref; Duck quack = new Duck(); bref = quack; A subtype may be assigned where the supertype is expected
More informationCMSC 341. Nilanjan Banerjee
CMSC 341 Nilanjan Banerjee http://www.csee.umbc.edu/~nilanb/teaching/341/ Announcements Just when you thought Shawn was going to teach this course! On a serious note: register on Piazza I like my classes
More informationCourse Description. Learn To: : Intro to JAVA SE7 and Programming using JAVA SE7. Course Outline ::
Module Title Duration : Intro to JAVA SE7 and Programming using JAVA SE7 : 9 days Course Description The Java SE 7 Fundamentals course was designed to enable students with little or no programming experience
More informationObject Oriented Programming. Java-Lecture 11 Polymorphism
Object Oriented Programming Java-Lecture 11 Polymorphism Abstract Classes and Methods There will be a situation where you want to develop a design of a class which is common to many classes. Abstract class
More informationPeter Sestoft. Java Precisely. Third Edition. The MIT Press Cambridge, Massachusetts London, England
Peter Sestoft Java Precisely Third Edition The MIT Press Cambridge, Massachusetts London, England Contents Preface Notational Conventions xi xii 1 Running Java: Compilation, Loading, and Execution 2 2
More informationImproving structure with inheritance
Objects First With Java A Practical Introduction Using BlueJ Improving structure with inheritance 2.0 Main concepts to be covered Inheritance Subtyping Substitution Polymorphic variables key concepts of
More informationOutline. More optimizations for our interpreter. Types for objects
Outline More optimizations for our interpreter Types for objects Optimization Eliminate tree walks: object creation, method calls fish initialize get_ grow eat colorfish color set_color get_color pickyfish
More informationApplication Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started
Application Development in JAVA Duration Lecture: Specialization x Hours Core Java (J2SE) & Advance Java (J2EE) Detailed Module Part I: Core Java (J2SE) Getting Started What is Java all about? Features
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationJAVA V Assertions Java, winter semester
JAVA Assertions 1 Assertion since Java 1.4 the statement with a boolean expression a developer supposes that the expression is always satisfied (evaluates to true) if it is evaluated to false -> error
More informationCOURSE 5 PROGRAMMING III OOP. JAVA LANGUAGE
COURSE 5 PROGRAMMING III OOP. JAVA LANGUAGE PREVIOUS COURSE CONTENT Generics Defining a generic Run-time behavior Collections List Set Map COUSE CONTENT Collections Utilities classes Aggregate Operations
More informationProgramming Lecture 3
Five-Minute Review 1. What is a variable? 2. What is a class? An object? 3. What is a package? 4. What is a method? A constructor? 5. What is an object variable? 1 Programming Lecture 3 Expressions etc.
More informationExam 2. Topics. Preconditions vs. Exceptions. Exam 2 Review. Exam 2 on Thursday, March 29 th. Closed book, closed computer, closed phone
Exam 2 Exam 2 on Thursday, March 29 th Exam 2 Review Closed book, closed computer, closed phone You are allowed two cheat pages Either a standard 8.5x11-sized sheet filled on both sides or two standard
More informationSoftware Construction
Lecture 7: Type Hierarchy, Iteration Abstraction Software Construction in Java for HSE Moscow Tom Verhoeff Eindhoven University of Technology Department of Mathematics & Computer Science Software Engineering
More informationObject-Oriented Programming More Inheritance
Object-Oriented Programming More Inheritance Ewan Klein School of Informatics Inf1 :: 2009/10 Ewan Klein (School of Informatics) OOP: More Inheritance Inf1 :: 2009/10 1 / 45 1 Inheritance Flat Hierarchy
More informationCOP 3330 Final Exam Review
COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time
More informationObject Orientation Fourth Story. Bok, Jong Soon
Object Orientation Fourth Story Bok, Jong Soon javaexpert@nate.com www.javaexpert.co.kr abstract Methods Java allows you to specify that a superclass declares a method that does not supply an implementation.
More information11/7/18 JAVA GENERICS. Java Collections. Java Collections. Using Java Collections. Proposals for adding Generics to Java.
JAVA GENERICS Lecture CS110 Fall 018 Photo credit: Andrew Kennedy Java Collections Early versions of Java lacked generics interface Collection { /** Return true iff the collection contains ob */ boolean
More informationLecture Notes Chapter #9 Summery. Inheritance
Lecture Notes Chapter #9 Summery Inheritance Subclass inherits all members of its superclass except its constructors methods inherited from a superclass can overridden in the subclass o a method overrides
More informationChapter 5 Object-Oriented Programming
Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares
More informationJava Generics Java, summer semester
Java Generics Introduction similar to the templates in C#/C++ but only on first view typed arguments goal clear code type safety Motivational example without generics (
More informationCS Programming I: Inheritance
CS 200 - Programming I: Inheritance Marc Renault Department of Computer Sciences University of Wisconsin Madison Fall 2017 TopHat Sec 3 (PM) Join Code: 719946 TopHat Sec 4 (AM) Join Code: 891624 Inheritance
More informationAdvanced Topics in Java and on Security in Systems Effective Generics. Eirik Eltvik 26 th of February 2007
Advanced Topics in Java and on Security in Systems Effective Generics Eirik Eltvik 26 th of February 2007 Taking care when calling Legacy code Checks at compile-time is not always appropriate When? Legacy
More informationExamination Questions Midterm 1
CS1102s Data Structures and Algorithms 10/2/2010 Examination Questions Midterm 1 This examination question booklet has 9 pages, including this cover page, and contains 15 questions. You have 40 minutes
More information25. Generic Programming
25. Generic Programming Java Fall 2009 Instructor: Dr. Masoud Yaghini Generic Programming Outline Polymorphism and Generic Programming Casting Objects and the instanceof Operator The protected Data and
More information