SlideShare a Scribd company logo
1 of 15
Download to read offline
METHOD
TA LESSON @ 108-1 JAVA
OUTLINE
‣ Static method & Non-static method
‣ Return value
‣ Variable & Out of scope
‣ Lab
STATIC METHOD &
NON-STATIC METHOD
STATIC METHOD & NON-STATIC METHOD
STATIC METHOD & NON-STATIC METHOD
▸ Static method 可以不被實例例化就使⽤用
▸ Non-static method 必須被實例例化(宣告物件)才能使⽤用
▸ Well known static method:
▸ public static void main(String args[])
STATIC METHOD & NON-STATIC METHOD
EXAMPLE
RETURN VALUE
RETURN VALUE
RETURN VALUE
▸ 每個 function 都會定義他的回傳值
▸ E.g. public static void main(String args[])
▸ 就像我們在定義變數的資料型別⼀一樣,我們會定義function的
回傳型別,來來決定回傳值要得到的資料型別
RETURN VALUE
METHOD
public static void main(String args[])
封裝
等級
靜態
or
非靜態
回傳
型別
函式名稱
and
參參數
RETURN VALUE
EXAMPLE
VARIABLE&
OUT OF SCOPE
VARIABLE & OUT OF SCOPE
OUT OF SCOPE
▸ 變數是有存取範圍的,當超出範圍時就不能被存取
▸ 舉個最簡單的例例⼦子: for 迴圈
▸ for(int i=0 ; i<10 ; i++){System.out.println(i);}
▸ 變數 i 在 for 迴圈結束後就不再能夠被存取
▸ 另⼀一個例例⼦子: Global variable & Local variable
LAB
LAB
LAB
1. 請完成兩兩個method來來讓main function正常執⾏行行
2. 第⼀一個method回傳值為void
3. 第⼆二個method回傳值為String
4. method的參參數必須⾃自⾏行行設置
5. main function第⼀一⾏行行印出HowHow,第⼆二⾏行行印出
HowHowAfuSevenfat
6.
LAB
EXAMPLE CODE
Q&A

More Related Content

What's hot

Js 函数 function学习笔记
Js 函数 function学习笔记Js 函数 function学习笔记
Js 函数 function学习笔记keke302
 
C++中级培训胶片
C++中级培训胶片C++中级培训胶片
C++中级培训胶片ff1
 
單元測試:Mocha、Chai 和 Sinon
單元測試:Mocha、Chai 和 Sinon單元測試:Mocha、Chai 和 Sinon
單元測試:Mocha、Chai 和 SinonHsin-Hao Tang
 
改善程序设计技术的50个有效做法
改善程序设计技术的50个有效做法改善程序设计技术的50个有效做法
改善程序设计技术的50个有效做法crasysatan
 
Java注解详解
Java注解详解Java注解详解
Java注解详解zlzl245437
 
3, operators
3, operators3, operators
3, operatorsted-xu
 
A Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard LibraryA Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard LibraryWen Liao
 

What's hot (10)

Js 函数 function学习笔记
Js 函数 function学习笔记Js 函数 function学习笔记
Js 函数 function学习笔记
 
C++中级培训胶片
C++中级培训胶片C++中级培训胶片
C++中级培训胶片
 
單元測試:Mocha、Chai 和 Sinon
單元測試:Mocha、Chai 和 Sinon單元測試:Mocha、Chai 和 Sinon
單元測試:Mocha、Chai 和 Sinon
 
改善程序设计技术的50个有效做法
改善程序设计技术的50个有效做法改善程序设计技术的50个有效做法
改善程序设计技术的50个有效做法
 
sorting
sortingsorting
sorting
 
SCJP ch04
SCJP ch04SCJP ch04
SCJP ch04
 
Java注解详解
Java注解详解Java注解详解
Java注解详解
 
3, operators
3, operators3, operators
3, operators
 
Ch08
Ch08Ch08
Ch08
 
A Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard LibraryA Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
 

More from Redhung @ Nationtal Chung Cheng University, Chiayi, Taiwan.

More from Redhung @ Nationtal Chung Cheng University, Chiayi, Taiwan. (17)

Windows Offender_ Reverse Engineering Windows Defender's Antivirus Emulator
Windows Offender_ Reverse Engineering Windows Defender's Antivirus EmulatorWindows Offender_ Reverse Engineering Windows Defender's Antivirus Emulator
Windows Offender_ Reverse Engineering Windows Defender's Antivirus Emulator
 
AEG_ Automatic Exploit Generation
AEG_ Automatic Exploit GenerationAEG_ Automatic Exploit Generation
AEG_ Automatic Exploit Generation
 
Unleashing MAYHEM On Binary Code
Unleashing MAYHEM On Binary CodeUnleashing MAYHEM On Binary Code
Unleashing MAYHEM On Binary Code
 
Firmadyne
FirmadyneFirmadyne
Firmadyne
 
Fintech Newebpay API using Flask and VueJS
Fintech Newebpay API using Flask and VueJSFintech Newebpay API using Flask and VueJS
Fintech Newebpay API using Flask and VueJS
 
TA Lesson Web-109
TA Lesson Web-109TA Lesson Web-109
TA Lesson Web-109
 
TA Lesson Binary Exploitation (Pwn)
TA Lesson Binary Exploitation (Pwn)TA Lesson Binary Exploitation (Pwn)
TA Lesson Binary Exploitation (Pwn)
 
Java - TA課 - Array
Java - TA課 - ArrayJava - TA課 - Array
Java - TA課 - Array
 
Reverse Engineering - Assembly & Introduction
Reverse Engineering - Assembly & IntroductionReverse Engineering - Assembly & Introduction
Reverse Engineering - Assembly & Introduction
 
Web Introduction
Web IntroductionWeb Introduction
Web Introduction
 
Java - TA課 - Let's Begin
Java - TA課 - Let's BeginJava - TA課 - Let's Begin
Java - TA課 - Let's Begin
 
Java - TA課 - 開發環境
Java - TA課 - 開發環境Java - TA課 - 開發環境
Java - TA課 - 開發環境
 
IoT Penetration Talk
IoT Penetration TalkIoT Penetration Talk
IoT Penetration Talk
 
Introduction to computer network
Introduction to computer networkIntroduction to computer network
Introduction to computer network
 
Assembly Language Redhung ( x86 ) @ TDOH
Assembly Language Redhung ( x86 ) @ TDOHAssembly Language Redhung ( x86 ) @ TDOH
Assembly Language Redhung ( x86 ) @ TDOH
 
TP-Link SR20 Zero-day attack
TP-Link SR20 Zero-day attackTP-Link SR20 Zero-day attack
TP-Link SR20 Zero-day attack
 
滲透測試入門 Penetration test - white hat hacking introduction
 滲透測試入門 Penetration test - white hat hacking introduction 滲透測試入門 Penetration test - white hat hacking introduction
滲透測試入門 Penetration test - white hat hacking introduction
 

TA Lesson3 - Method