tailieunhanh - Lecter Java: Program design - Chapter 3: Objects

Learning objectives of this chapter include: Develop a mental model of an object and a reference; describe how to define and use object type constants and variables; explain the roles of constructors, member methods, and class methods; present object assignment; introduce the String class and its methods for creating, examining, searching, evaluating, and manipulating substrings and characters. | Objects Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Getting classy Your current job Gain experience creating and manipulating objects from the standard Java types Why Prepares you for defining your own classes and creating and manipulating the objects of those classes Values versus objects Numbers Have values but they do not have behaviors Objects Have attributes and behaviors References an InputStream Attribute: keyboard Behaviors: reading References an OutputStream Attribute: monitor Behaviors: printing Java treats object variables differently. Although an object variable is the symbolic name for a memory location being used by the program, the memory location for an object variable does not store a value of that object type. Instead the value in the memory location tells the program where to find a value (object) of that type. We say that an object variable references or points to an object of the object type. . | Objects Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Getting classy Your current job Gain experience creating and manipulating objects from the standard Java types Why Prepares you for defining your own classes and creating and manipulating the objects of those classes Values versus objects Numbers Have values but they do not have behaviors Objects Have attributes and behaviors References an InputStream Attribute: keyboard Behaviors: reading References an OutputStream Attribute: monitor Behaviors: printing Java treats object variables differently. Although an object variable is the symbolic name for a memory location being used by the program, the memory location for an object variable does not store a value of that object type. Instead the value in the memory location tells the program where to find a value (object) of that type. We say that an object variable references or points to an object of the object type. Thus, a String variable references a memory location that holds a value of type String. Similarly, a BufferedReader variable references a memory location holding a BufferedReader value. Some other Java object types Scanner String Rectangle Color JFrame Consider Statements int peasPerPod = 8; String message = "Don't look behind the door!“ How show we represent these definitions according to the notions of Java? Java treats object variables differently. Although an object variable is the symbolic name for a memory location being used by the program, the memory location for an object variable does not store a value of that object type. Instead the value in the memory location tells the program where to find a value (object) of that type. We say that an object variable references or points to an object of the object type. Thus, a String variable references a memory location that holds a value of type String. Similarly, a BufferedReader variable references a memory location holding a .

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã 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.