Download presentation
Presentation is loading. Please wait.
1
Java @Ch10. Thinking in Objects 2010.12.24
2
Outline The this Reference [Sample code] PressEnter.java
3
The this Reference Public class Foo { int i = 5; static double k = 0; void setI(int i) { this.i = i; } static void setK(double k) { Foo.k = k; } Suppose that f1 and f2 are two objects of Foo. Invoking f1.setI(10) is to execute this.i = 10, where this refers f1 Invoking f2.setI(45) is to execute this.i = 45, where this refers f2 ( The this keyword is name of a reference that refers to a calling object itself. )
4
程式練習 : (16 進位轉 10 進位 ) 1. 輸入一個 16 進位數, 例如 : F 2. 印出它的 10 進位數, F 15
5
程式範例 : ( 判斷鍵盤按下 Enter 鍵 ) PressEnter.java
6
GUI File Dialogs 程式範例 : ( 視窗介面檔案選擇 ) Listing 9.10 ReadFileUsingJFileChooser.java
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.