SlideShare ist ein Scribd-Unternehmen logo
1 von 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]

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 

Kürzlich hochgeladen (20)

Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 

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.