SlideShare a Scribd company logo
1 of 81
Download to read offline
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]

More Related Content

What's hot

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
 

What's hot (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
 

Similar to 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
 

Similar to 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
 

More from 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
 

More from 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
 

Recently uploaded

Top 10 Squarespace Development Companies
Top 10 Squarespace Development CompaniesTop 10 Squarespace Development Companies
Top 10 Squarespace Development CompaniesTopCSSGallery
 
Oracle Database 23c Security New Features.pptx
Oracle Database 23c Security New Features.pptxOracle Database 23c Security New Features.pptx
Oracle Database 23c Security New Features.pptxSatishbabu Gunukula
 
The Importance of Indoor Air Quality (English)
The Importance of Indoor Air Quality (English)The Importance of Indoor Air Quality (English)
The Importance of Indoor Air Quality (English)IES VE
 
Patch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 updatePatch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 updateadam112203
 
Novo Nordisk's journey in developing an open-source application on Neo4j
Novo Nordisk's journey in developing an open-source application on Neo4jNovo Nordisk's journey in developing an open-source application on Neo4j
Novo Nordisk's journey in developing an open-source application on Neo4jNeo4j
 
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxGraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxNeo4j
 
Keep Your Finger on the Pulse of Your Building's Performance with IES Live
Keep Your Finger on the Pulse of Your Building's Performance with IES LiveKeep Your Finger on the Pulse of Your Building's Performance with IES Live
Keep Your Finger on the Pulse of Your Building's Performance with IES LiveIES VE
 
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxEmil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxNeo4j
 
Where developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is goingWhere developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is goingFrancesco Corti
 
Scenario Library et REX Discover industry- and role- based scenarios
Scenario Library et REX Discover industry- and role- based scenariosScenario Library et REX Discover industry- and role- based scenarios
Scenario Library et REX Discover industry- and role- based scenariosErol GIRAUDY
 
UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4DianaGray10
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
My key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAIMy key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAIVijayananda Mohire
 
From the origin to the future of Open Source model and business
From the origin to the future of  Open Source model and businessFrom the origin to the future of  Open Source model and business
From the origin to the future of Open Source model and businessFrancesco Corti
 
Graphene Quantum Dots-Based Composites for Biomedical Applications
Graphene Quantum Dots-Based Composites for  Biomedical ApplicationsGraphene Quantum Dots-Based Composites for  Biomedical Applications
Graphene Quantum Dots-Based Composites for Biomedical Applicationsnooralam814309
 
Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)Muhammad Tiham Siddiqui
 
2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdf2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdfThe Good Food Institute
 
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc
 
Stobox 4: Revolutionizing Investment in Real-World Assets Through Tokenization
Stobox 4: Revolutionizing Investment in Real-World Assets Through TokenizationStobox 4: Revolutionizing Investment in Real-World Assets Through Tokenization
Stobox 4: Revolutionizing Investment in Real-World Assets Through TokenizationStobox
 

Recently uploaded (20)

Top 10 Squarespace Development Companies
Top 10 Squarespace Development CompaniesTop 10 Squarespace Development Companies
Top 10 Squarespace Development Companies
 
Oracle Database 23c Security New Features.pptx
Oracle Database 23c Security New Features.pptxOracle Database 23c Security New Features.pptx
Oracle Database 23c Security New Features.pptx
 
The Importance of Indoor Air Quality (English)
The Importance of Indoor Air Quality (English)The Importance of Indoor Air Quality (English)
The Importance of Indoor Air Quality (English)
 
Patch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 updatePatch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 update
 
Novo Nordisk's journey in developing an open-source application on Neo4j
Novo Nordisk's journey in developing an open-source application on Neo4jNovo Nordisk's journey in developing an open-source application on Neo4j
Novo Nordisk's journey in developing an open-source application on Neo4j
 
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxGraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
 
Keep Your Finger on the Pulse of Your Building's Performance with IES Live
Keep Your Finger on the Pulse of Your Building's Performance with IES LiveKeep Your Finger on the Pulse of Your Building's Performance with IES Live
Keep Your Finger on the Pulse of Your Building's Performance with IES Live
 
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxEmil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
 
Where developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is goingWhere developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is going
 
Scenario Library et REX Discover industry- and role- based scenarios
Scenario Library et REX Discover industry- and role- based scenariosScenario Library et REX Discover industry- and role- based scenarios
Scenario Library et REX Discover industry- and role- based scenarios
 
UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
My key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAIMy key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAI
 
SheDev 2024
SheDev 2024SheDev 2024
SheDev 2024
 
From the origin to the future of Open Source model and business
From the origin to the future of  Open Source model and businessFrom the origin to the future of  Open Source model and business
From the origin to the future of Open Source model and business
 
Graphene Quantum Dots-Based Composites for Biomedical Applications
Graphene Quantum Dots-Based Composites for  Biomedical ApplicationsGraphene Quantum Dots-Based Composites for  Biomedical Applications
Graphene Quantum Dots-Based Composites for Biomedical Applications
 
Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)
 
2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdf2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdf
 
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
 
Stobox 4: Revolutionizing Investment in Real-World Assets Through Tokenization
Stobox 4: Revolutionizing Investment in Real-World Assets Through TokenizationStobox 4: Revolutionizing Investment in Real-World Assets Through Tokenization
Stobox 4: Revolutionizing Investment in Real-World Assets Through Tokenization
 

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.