Lecture Software construction - Lecture 9: Java implementation - Part 4

This chapter presents the following content: Enum types; memory allocation: another view of java’s type system; object identity, assignment, equality, and copying; the object class; overriding equals() and tostring(); cloning; nested classes. | Java Implementation: Part 4 Software Construction Lecture 9 1 Agenda 2 Topics: Enum Types Memory allocation: another view of Java’s type system Object Identity, Assignment, Equality, and Copying The Object class Overriding equals() and toString() Cloning Nested Classes What and Why Reading, in The Java Tutorials: Enum Types and Nested Classes pages, in the Classes and Objects Lesson. Object as a Superclass page, in the Interface and Inheritance Lesson. Equality, Relational, and Conditional Operators page, in the Language Basics Lesson. For reference: The 3 things you should know about hashCode(), Eclipse Source Developer, available 20 March 2013. Learning objectives for this week 3 Students will be competent at implementing OO designs in Java Enums, memory allocation, object identity & assignment & equality & cloning, nested classes The lectures will give you the basic “theory”, but they won’t give you a “working understanding” – you have to do the hard-yards of putting these ideas . | Java Implementation: Part 4 Software Construction Lecture 9 1 Agenda 2 Topics: Enum Types Memory allocation: another view of Java’s type system Object Identity, Assignment, Equality, and Copying The Object class Overriding equals() and toString() Cloning Nested Classes What and Why Reading, in The Java Tutorials: Enum Types and Nested Classes pages, in the Classes and Objects Lesson. Object as a Superclass page, in the Interface and Inheritance Lesson. Equality, Relational, and Conditional Operators page, in the Language Basics Lesson. For reference: The 3 things you should know about hashCode(), Eclipse Source Developer, available 20 March 2013. Learning objectives for this week 3 Students will be competent at implementing OO designs in Java Enums, memory allocation, object identity & assignment & equality & cloning, nested classes The lectures will give you the basic “theory”, but they won’t give you a “working understanding” – you have to do the hard-yards of putting these ideas into practice. You won’t even understand the theory, if you listen passively to lectures. I’ll try to help you “learn how to learn” from the Java tutorials. You’ll get many chances to develop your understanding in your lab assignments for this course. Enum Types 4 “An enum type is a special data type that enables for a variable to be a set of predefined constants. The variable must be equal to one of the values that have been predefined for it. Common examples include compass directions (values of NORTH, SOUTH, EAST, and WEST) and the days of the week. “Because they are constants, the names of an enum type's fields are in uppercase letters. “ define an enum type by using the enum keyword. For example, you would specify a days-of-the-week enum type as: “You should use enum types any time you need to represent a fixed set of constants. That includes natural enum types such as the planets in our solar system and data sets where you know all possible values at compile time—for example, the

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.