Thư viện tài liệu trực tuyến miễn phí dành cho các bạn học sinh, sinh viên
To open a file for reading objects, create a FileInputStream wrapped by an ObjectInputStream FileInputStream provides methods for reading byte-based input from a file ObjectInputStream uses FileInputStream to read objects from file ObjectInputStream method readObject reads in object, which is then downcast to proper type EOFException occurs if ...
82 trang | Chia sẻ: huyhoang44 | Ngày: 17/03/2020 | Lượt xem: 1191 | Lượt tải: 0
Assertions are conditions that should be true at a particular point in a method Help ensure a program’s validity by catching potential bugs Preconditions and Postconditions are two kinds of assertions Assertions can be stated as comments or assertions can be validated programmatically using the assert statement
90 trang | Chia sẻ: huyhoang44 | Ngày: 17/03/2020 | Lượt xem: 1136 | Lượt tải: 0
An ArrayIndexOutOfBoundsException is thrown if the number of points specified in the third argument to method drawPolygon or method fillPolygon is greater than the number of elements in the arrays of coordinates that specify the polygon to display.
74 trang | Chia sẻ: huyhoang44 | Ngày: 17/03/2020 | Lượt xem: 1103 | Lượt tải: 0
It is possible to set a Container’s layout to null, which indicates that no layout manager should be used. In a Container without a layout manager, the programmer must position and size the components in the given container and take care that, on resize events, all components are repositioned as necessary. A component’s resize events can be process...
174 trang | Chia sẻ: huyhoang44 | Ngày: 17/03/2020 | Lượt xem: 977 | Lượt tải: 0
Using a superclass reference, we can polymorphically invoke any method specified in the superclass declaration (and in class Object). Using an interface reference, we can polymorphically invoke any method specified in the interface declaration (and in class Object).
90 trang | Chia sẻ: huyhoang44 | Ngày: 17/03/2020 | Lượt xem: 1194 | Lượt tải: 0
At the design stage in an object-oriented system, the designer often finds that certain classes are closely related. The designer should “factor out” common instance variables and methods and place them in a superclass. Then the designer should use inheritance to develop subclasses, specializing them with capabilities beyond those inherited from th...
89 trang | Chia sẻ: huyhoang44 | Ngày: 17/03/2020 | Lượt xem: 1507 | Lượt tải: 0
Not initializing a final instance variable in its declaration or in every constructor of the class yields a compilation error indicating that the variable might not have been initialized. The same error occurs if the class initializes the variable in some, but not all, of the class’s constructors.
118 trang | Chia sẻ: huyhoang44 | Ngày: 17/03/2020 | Lượt xem: 1396 | Lượt tải: 0
Command-line arguments Pass arguments from the command line String args[] Appear after the class name in the java command java MyClass a b Number of arguments passed in from command line args.length First command-line argument args[ 0 ]
100 trang | Chia sẻ: huyhoang44 | Ngày: 17/03/2020 | Lượt xem: 1118 | Lượt tải: 0
Enumerations Programmer-declared types consisting of sets of constants enum keyword A type name (e.g. Status) Enumeration constants (e.g. WON, LOST and CONTINUE) cannot be compared against ints
88 trang | Chia sẻ: huyhoang44 | Ngày: 17/03/2020 | Lượt xem: 1119 | Lượt tải: 0
State Machine Diagrams Commonly called state diagram Model several states of an object Show under what circumstances the object changes state Focus on system behavior UML representation State Rounded rectangle Initial state Solid circle Transitions Arrows with stick arrowheads
95 trang | Chia sẻ: huyhoang44 | Ngày: 17/03/2020 | Lượt xem: 1160 | Lượt tải: 0