SlideShare une entreprise Scribd logo
1  sur  81
Java Programming: From Problem Analysis to Program Design, 5e Chapter 7 User-Defined Methods
Chapter Objectives ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Chapter Objectives (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Predefined Classes ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Predefined Classes (continued) Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e Predefined Classes (continued)
Java Programming: From Problem Analysis to Program Design, 5e Predefined Classes (continued)
Java Programming: From Problem Analysis to Program Design, 5e Predefined Classes (continued)
class  Character   (Package:  java.lang ) Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e class  Character   (Package:  java.lang ) (continued)
Java Programming: From Problem Analysis to Program Design, 5e class  Character   (Package:  java.lang ) (continued)
Java Programming: From Problem Analysis to Program Design, 5e To simplify the use of (public) static methods of a class, Java 5.0 introduces the following import statements: These are called static import statements. After including such statements in your program, when you use a (public) static method (or any other public static member) of a class, you can omit the name of the class and the dot operator.
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Syntax: Value-Returning Method Java Programming: From Problem Analysis to Program Design, 5e
User-Defined Methods ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Syntax ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Syntax (continued) ,[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object],[object Object]
Equivalent Method Definitions Java Programming: From Problem Analysis to Program Design, 5e public static double  larger( double  x,  double  y) { double   max; if   (x >= y) max = x; else max = y; return   max; }
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Equivalent Method Definitions (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Equivalent Method Definitions (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e The  int  variable  num  contains the desired sum to be rolled
Palindrome Number ,[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Solution:  isPalindrome  Method Java Programming: From Problem Analysis to Program Design, 5e public static boolean  isPalindrome(String str) { int  len = str.length();  int  i, j; j = len - 1;  for  (i = 0; i <= (len - 1) / 2; i++) { if  (str.charAt(i) !=  str.charAt(j)) return false ; j--;  } return true ;  }
Flow of Execution ,[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Programming Example: Largest Number ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Solution: Largest Number Java Programming: From Problem Analysis to Program Design, 5e static  Scanner console =  new  Scanner(System.in); public static void  main(String[] args) { double  num; double  max;  int  count; System.out.println(&quot;Enter 10 numbers.&quot;); num = console.nextDouble();  max = num;  for  (count = 1; count < 10; count++)  { num = console.nextDouble();  max = larger(max, num);  } System.out.println(&quot;The largest number is &quot; + max);  }
Sample Run: Largest Number Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object],[object Object],[object Object]
Void Methods ,[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Void Methods with Parameters: Syntax Java Programming: From Problem Analysis to Program Design, 5e
Void Methods with Parameters: Syntax (continued) Java Programming: From Problem Analysis to Program Design, 5e
Primitive Data Type Variables as Parameters ,[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Reference Variables as Parameters   ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Uses of  Reference Variables as Parameters   ,[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Reference Variables as Parameters: type  String Java Programming: From Problem Analysis to Program Design, 5e
Reference Variables as Parameters: type  String  (continued) Java Programming: From Problem Analysis to Program Design, 5e
Reference Variables as Parameters: type  String  (continued) Java Programming: From Problem Analysis to Program Design, 5e
Reference Variables as Parameters: type  String  (continued) Java Programming: From Problem Analysis to Program Design, 5e
Reference Variables as Parameters: type  String  (continued) Java Programming: From Problem Analysis to Program Design, 5e String str = &quot;Hello&quot;;  //Line 5
Reference Variables as Parameters: type  String  (continued) Java Programming: From Problem Analysis to Program Design, 5e stringParameter(str);  //Line 7
Reference Variables as Parameters: type  String  (continued) Java Programming: From Problem Analysis to Program Design, 5e pStr = &quot;Sunny Day&quot;;  //Line 14
Reference Variables as Parameters: type  String  (continued) Java Programming: From Problem Analysis to Program Design, 5e Variables before the statement in Line 8 executes
Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object]
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Scope of an Identifier within a Class ,[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Scope of an Identifier within a Class (continued) ,[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Scope of an Identifier within a Class (continued) ,[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Scope of an Identifier within a Class (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Scope Rules ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Scope Rules (continued) ,[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Scope Rules (continued) Java Programming: From Problem Analysis to Program Design, 5e
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Scope Rules (continued) Java Programming: From Problem Analysis to Program Design, 5e
Scope Rules: Demonstrated Java Programming: From Problem Analysis to Program Design, 5e
Scope Rules: Demonstrated (continued) Java Programming: From Problem Analysis to Program Design, 5e
Method Overloading:  An Introduction ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Method Overloading ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Method Overloading (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Method Overloading (continued) ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Method Overloading (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Method Overloading (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Programming Example: Data Comparison ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Programming Example: Data Comparison (continued) Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e Programming Example: Data Comparison (continued)
Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object],[object Object]
Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object],[object Object],[object Object],[object Object]
Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object],[object Object],[object Object]
Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object],[object Object],[object Object],[object Object]
Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object],[object Object],[object Object],[object Object]
Chapter Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Chapter Summary (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Chapter Summary (continued) Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object]

Contenu connexe

Tendances

9781111530532 ppt ch04
9781111530532 ppt ch049781111530532 ppt ch04
9781111530532 ppt ch04Terry Yoast
 
Chapter 2 - Basic Elements of Java
Chapter 2 - Basic Elements of JavaChapter 2 - Basic Elements of Java
Chapter 2 - Basic Elements of JavaAdan Hubahib
 
9781111530532 ppt ch01
9781111530532 ppt ch019781111530532 ppt ch01
9781111530532 ppt ch01Terry Yoast
 
9781439035665 ppt ch07
9781439035665 ppt ch079781439035665 ppt ch07
9781439035665 ppt ch07Terry Yoast
 
9781439035665 ppt ch02
9781439035665 ppt ch029781439035665 ppt ch02
9781439035665 ppt ch02Terry Yoast
 
9781111530532 ppt ch10
9781111530532 ppt ch109781111530532 ppt ch10
9781111530532 ppt ch10Terry Yoast
 
9781111530532 ppt ch05
9781111530532 ppt ch059781111530532 ppt ch05
9781111530532 ppt ch05Terry Yoast
 
9781439035665 ppt ch05
9781439035665 ppt ch059781439035665 ppt ch05
9781439035665 ppt ch05Terry Yoast
 
9781439035665 ppt ch04
9781439035665 ppt ch049781439035665 ppt ch04
9781439035665 ppt ch04Terry Yoast
 
9781439035665 ppt ch06
9781439035665 ppt ch069781439035665 ppt ch06
9781439035665 ppt ch06Terry Yoast
 
9781111530532 ppt ch02
9781111530532 ppt ch029781111530532 ppt ch02
9781111530532 ppt ch02Terry Yoast
 
9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjects9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjectsTerry Yoast
 

Tendances (15)

9781111530532 ppt ch04
9781111530532 ppt ch049781111530532 ppt ch04
9781111530532 ppt ch04
 
Chapter 2 - Basic Elements of Java
Chapter 2 - Basic Elements of JavaChapter 2 - Basic Elements of Java
Chapter 2 - Basic Elements of Java
 
9781111530532 ppt ch01
9781111530532 ppt ch019781111530532 ppt ch01
9781111530532 ppt ch01
 
9781439035665 ppt ch07
9781439035665 ppt ch079781439035665 ppt ch07
9781439035665 ppt ch07
 
9781439035665 ppt ch02
9781439035665 ppt ch029781439035665 ppt ch02
9781439035665 ppt ch02
 
9781111530532 ppt ch10
9781111530532 ppt ch109781111530532 ppt ch10
9781111530532 ppt ch10
 
9781111530532 ppt ch05
9781111530532 ppt ch059781111530532 ppt ch05
9781111530532 ppt ch05
 
9781439035665 ppt ch05
9781439035665 ppt ch059781439035665 ppt ch05
9781439035665 ppt ch05
 
9781439035665 ppt ch04
9781439035665 ppt ch049781439035665 ppt ch04
9781439035665 ppt ch04
 
Chapter 12
Chapter 12Chapter 12
Chapter 12
 
Chap04
Chap04Chap04
Chap04
 
9781439035665 ppt ch06
9781439035665 ppt ch069781439035665 ppt ch06
9781439035665 ppt ch06
 
9781111530532 ppt ch02
9781111530532 ppt ch029781111530532 ppt ch02
9781111530532 ppt ch02
 
Pptchapter04
Pptchapter04Pptchapter04
Pptchapter04
 
9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjects9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjects
 

Similaire à 9781111530532 ppt ch07

9781111530532 ppt ch03
9781111530532 ppt ch039781111530532 ppt ch03
9781111530532 ppt ch03Terry Yoast
 
9781111530532 ppt ch02
9781111530532 ppt ch029781111530532 ppt ch02
9781111530532 ppt ch02Terry Yoast
 
9781439035665 ppt ch03
9781439035665 ppt ch039781439035665 ppt ch03
9781439035665 ppt ch03Terry Yoast
 
9781111530532 ppt ch04
9781111530532 ppt ch049781111530532 ppt ch04
9781111530532 ppt ch04Terry Yoast
 
9781111530532 ppt ch05
9781111530532 ppt ch059781111530532 ppt ch05
9781111530532 ppt ch05Terry Yoast
 
9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjects9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjectsTerry Yoast
 
Java method present by showrov ahamed
Java method present by showrov ahamedJava method present by showrov ahamed
Java method present by showrov ahamedMd Showrov Ahmed
 
9781111530532 ppt ch06
9781111530532 ppt ch069781111530532 ppt ch06
9781111530532 ppt ch06Terry Yoast
 
9781439035665 ppt ch07_passing_primitivetypeasobjects
9781439035665 ppt ch07_passing_primitivetypeasobjects9781439035665 ppt ch07_passing_primitivetypeasobjects
9781439035665 ppt ch07_passing_primitivetypeasobjectsTerry Yoast
 
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...vekariyakashyap
 

Similaire à 9781111530532 ppt ch07 (19)

9781111530532 ppt ch03
9781111530532 ppt ch039781111530532 ppt ch03
9781111530532 ppt ch03
 
9781111530532 ppt ch02
9781111530532 ppt ch029781111530532 ppt ch02
9781111530532 ppt ch02
 
Chap07
Chap07Chap07
Chap07
 
9781439035665 ppt ch03
9781439035665 ppt ch039781439035665 ppt ch03
9781439035665 ppt ch03
 
9781111530532 ppt ch04
9781111530532 ppt ch049781111530532 ppt ch04
9781111530532 ppt ch04
 
Chap02
Chap02Chap02
Chap02
 
Chap03
Chap03Chap03
Chap03
 
Chap03
Chap03Chap03
Chap03
 
9781111530532 ppt ch05
9781111530532 ppt ch059781111530532 ppt ch05
9781111530532 ppt ch05
 
Chapter 13
Chapter 13Chapter 13
Chapter 13
 
9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjects9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjects
 
Chap14
Chap14Chap14
Chap14
 
Java method present by showrov ahamed
Java method present by showrov ahamedJava method present by showrov ahamed
Java method present by showrov ahamed
 
9781111530532 ppt ch06
9781111530532 ppt ch069781111530532 ppt ch06
9781111530532 ppt ch06
 
9781439035665 ppt ch07_passing_primitivetypeasobjects
9781439035665 ppt ch07_passing_primitivetypeasobjects9781439035665 ppt ch07_passing_primitivetypeasobjects
9781439035665 ppt ch07_passing_primitivetypeasobjects
 
Chap13
Chap13Chap13
Chap13
 
UNIT1-JAVA.pptx
UNIT1-JAVA.pptxUNIT1-JAVA.pptx
UNIT1-JAVA.pptx
 
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
 
Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
 

Plus de Terry Yoast

9781305078444 ppt ch12
9781305078444 ppt ch129781305078444 ppt ch12
9781305078444 ppt ch12Terry Yoast
 
9781305078444 ppt ch11
9781305078444 ppt ch119781305078444 ppt ch11
9781305078444 ppt ch11Terry Yoast
 
9781305078444 ppt ch10
9781305078444 ppt ch109781305078444 ppt ch10
9781305078444 ppt ch10Terry Yoast
 
9781305078444 ppt ch09
9781305078444 ppt ch099781305078444 ppt ch09
9781305078444 ppt ch09Terry Yoast
 
9781305078444 ppt ch08
9781305078444 ppt ch089781305078444 ppt ch08
9781305078444 ppt ch08Terry Yoast
 
9781305078444 ppt ch07
9781305078444 ppt ch079781305078444 ppt ch07
9781305078444 ppt ch07Terry Yoast
 
9781305078444 ppt ch06
9781305078444 ppt ch069781305078444 ppt ch06
9781305078444 ppt ch06Terry Yoast
 
9781305078444 ppt ch05
9781305078444 ppt ch059781305078444 ppt ch05
9781305078444 ppt ch05Terry Yoast
 
9781305078444 ppt ch04
9781305078444 ppt ch049781305078444 ppt ch04
9781305078444 ppt ch04Terry Yoast
 
9781305078444 ppt ch03
9781305078444 ppt ch039781305078444 ppt ch03
9781305078444 ppt ch03Terry Yoast
 
9781305078444 ppt ch02
9781305078444 ppt ch029781305078444 ppt ch02
9781305078444 ppt ch02Terry Yoast
 
9781305078444 ppt ch01
9781305078444 ppt ch019781305078444 ppt ch01
9781305078444 ppt ch01Terry Yoast
 
9781337102087 ppt ch13
9781337102087 ppt ch139781337102087 ppt ch13
9781337102087 ppt ch13Terry Yoast
 
9781337102087 ppt ch18
9781337102087 ppt ch189781337102087 ppt ch18
9781337102087 ppt ch18Terry Yoast
 
9781337102087 ppt ch17
9781337102087 ppt ch179781337102087 ppt ch17
9781337102087 ppt ch17Terry Yoast
 
9781337102087 ppt ch16
9781337102087 ppt ch169781337102087 ppt ch16
9781337102087 ppt ch16Terry Yoast
 
9781337102087 ppt ch15
9781337102087 ppt ch159781337102087 ppt ch15
9781337102087 ppt ch15Terry Yoast
 
9781337102087 ppt ch14
9781337102087 ppt ch149781337102087 ppt ch14
9781337102087 ppt ch14Terry Yoast
 
9781337102087 ppt ch12
9781337102087 ppt ch129781337102087 ppt ch12
9781337102087 ppt ch12Terry Yoast
 
9781337102087 ppt ch11
9781337102087 ppt ch119781337102087 ppt ch11
9781337102087 ppt ch11Terry Yoast
 

Plus de Terry Yoast (20)

9781305078444 ppt ch12
9781305078444 ppt ch129781305078444 ppt ch12
9781305078444 ppt ch12
 
9781305078444 ppt ch11
9781305078444 ppt ch119781305078444 ppt ch11
9781305078444 ppt ch11
 
9781305078444 ppt ch10
9781305078444 ppt ch109781305078444 ppt ch10
9781305078444 ppt ch10
 
9781305078444 ppt ch09
9781305078444 ppt ch099781305078444 ppt ch09
9781305078444 ppt ch09
 
9781305078444 ppt ch08
9781305078444 ppt ch089781305078444 ppt ch08
9781305078444 ppt ch08
 
9781305078444 ppt ch07
9781305078444 ppt ch079781305078444 ppt ch07
9781305078444 ppt ch07
 
9781305078444 ppt ch06
9781305078444 ppt ch069781305078444 ppt ch06
9781305078444 ppt ch06
 
9781305078444 ppt ch05
9781305078444 ppt ch059781305078444 ppt ch05
9781305078444 ppt ch05
 
9781305078444 ppt ch04
9781305078444 ppt ch049781305078444 ppt ch04
9781305078444 ppt ch04
 
9781305078444 ppt ch03
9781305078444 ppt ch039781305078444 ppt ch03
9781305078444 ppt ch03
 
9781305078444 ppt ch02
9781305078444 ppt ch029781305078444 ppt ch02
9781305078444 ppt ch02
 
9781305078444 ppt ch01
9781305078444 ppt ch019781305078444 ppt ch01
9781305078444 ppt ch01
 
9781337102087 ppt ch13
9781337102087 ppt ch139781337102087 ppt ch13
9781337102087 ppt ch13
 
9781337102087 ppt ch18
9781337102087 ppt ch189781337102087 ppt ch18
9781337102087 ppt ch18
 
9781337102087 ppt ch17
9781337102087 ppt ch179781337102087 ppt ch17
9781337102087 ppt ch17
 
9781337102087 ppt ch16
9781337102087 ppt ch169781337102087 ppt ch16
9781337102087 ppt ch16
 
9781337102087 ppt ch15
9781337102087 ppt ch159781337102087 ppt ch15
9781337102087 ppt ch15
 
9781337102087 ppt ch14
9781337102087 ppt ch149781337102087 ppt ch14
9781337102087 ppt ch14
 
9781337102087 ppt ch12
9781337102087 ppt ch129781337102087 ppt ch12
9781337102087 ppt ch12
 
9781337102087 ppt ch11
9781337102087 ppt ch119781337102087 ppt ch11
9781337102087 ppt ch11
 

Dernier

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Dernier (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

9781111530532 ppt ch07

  • 1. Java Programming: From Problem Analysis to Program Design, 5e Chapter 7 User-Defined Methods
  • 2.
  • 3.
  • 4.
  • 5. Predefined Classes (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 6. Java Programming: From Problem Analysis to Program Design, 5e Predefined Classes (continued)
  • 7. Java Programming: From Problem Analysis to Program Design, 5e Predefined Classes (continued)
  • 8. Java Programming: From Problem Analysis to Program Design, 5e Predefined Classes (continued)
  • 9. class Character (Package: java.lang ) Java Programming: From Problem Analysis to Program Design, 5e
  • 10. Java Programming: From Problem Analysis to Program Design, 5e class Character (Package: java.lang ) (continued)
  • 11. Java Programming: From Problem Analysis to Program Design, 5e class Character (Package: java.lang ) (continued)
  • 12. Java Programming: From Problem Analysis to Program Design, 5e To simplify the use of (public) static methods of a class, Java 5.0 introduces the following import statements: These are called static import statements. After including such statements in your program, when you use a (public) static method (or any other public static member) of a class, you can omit the name of the class and the dot operator.
  • 13. Java Programming: From Problem Analysis to Program Design, 5e
  • 14. Java Programming: From Problem Analysis to Program Design, 5e
  • 15. Java Programming: From Problem Analysis to Program Design, 5e
  • 16. Java Programming: From Problem Analysis to Program Design, 5e
  • 17. Syntax: Value-Returning Method Java Programming: From Problem Analysis to Program Design, 5e
  • 18.
  • 19.
  • 20.
  • 21. Equivalent Method Definitions Java Programming: From Problem Analysis to Program Design, 5e public static double larger( double x, double y) { double max; if (x >= y) max = x; else max = y; return max; }
  • 22. Java Programming: From Problem Analysis to Program Design, 5e
  • 23. Java Programming: From Problem Analysis to Program Design, 5e
  • 24.
  • 25.
  • 26. Java Programming: From Problem Analysis to Program Design, 5e The int variable num contains the desired sum to be rolled
  • 27.
  • 28. Solution: isPalindrome Method Java Programming: From Problem Analysis to Program Design, 5e public static boolean isPalindrome(String str) { int len = str.length(); int i, j; j = len - 1; for (i = 0; i <= (len - 1) / 2; i++) { if (str.charAt(i) != str.charAt(j)) return false ; j--; } return true ; }
  • 29.
  • 30.
  • 31. Solution: Largest Number Java Programming: From Problem Analysis to Program Design, 5e static Scanner console = new Scanner(System.in); public static void main(String[] args) { double num; double max; int count; System.out.println(&quot;Enter 10 numbers.&quot;); num = console.nextDouble(); max = num; for (count = 1; count < 10; count++) { num = console.nextDouble(); max = larger(max, num); } System.out.println(&quot;The largest number is &quot; + max); }
  • 32.
  • 33.
  • 34. Void Methods with Parameters: Syntax Java Programming: From Problem Analysis to Program Design, 5e
  • 35. Void Methods with Parameters: Syntax (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 36.
  • 37.
  • 38.
  • 39. Reference Variables as Parameters: type String Java Programming: From Problem Analysis to Program Design, 5e
  • 40. Reference Variables as Parameters: type String (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 41. Reference Variables as Parameters: type String (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 42. Reference Variables as Parameters: type String (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 43. Reference Variables as Parameters: type String (continued) Java Programming: From Problem Analysis to Program Design, 5e String str = &quot;Hello&quot;; //Line 5
  • 44. Reference Variables as Parameters: type String (continued) Java Programming: From Problem Analysis to Program Design, 5e stringParameter(str); //Line 7
  • 45. Reference Variables as Parameters: type String (continued) Java Programming: From Problem Analysis to Program Design, 5e pStr = &quot;Sunny Day&quot;; //Line 14
  • 46. Reference Variables as Parameters: type String (continued) Java Programming: From Problem Analysis to Program Design, 5e Variables before the statement in Line 8 executes
  • 47.
  • 48. Java Programming: From Problem Analysis to Program Design, 5e
  • 49. Java Programming: From Problem Analysis to Program Design, 5e
  • 50. Java Programming: From Problem Analysis to Program Design, 5e
  • 51. Java Programming: From Problem Analysis to Program Design, 5e
  • 52. Java Programming: From Problem Analysis to Program Design, 5e
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63. Scope Rules: Demonstrated Java Programming: From Problem Analysis to Program Design, 5e
  • 64. Scope Rules: Demonstrated (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73. Java Programming: From Problem Analysis to Program Design, 5e Programming Example: Data Comparison (continued)
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.