Week11Chap7-II

# Week11Chap7-II - Chapter 7 Arrays Lecture V Janaka...

• Notes
• 9

This preview shows pages 1–5. Sign up to view the full content.

Janaka Balasooriya CSE 110, Arizona State University Chapter 7 Arrays - Lecture V

This preview has intentionally blurred sections. Sign up to view the full version.

Janaka Balasooriya CSE 110, Arizona State University Arrays as Method Parameters: Homework Solutions • We can pass arrays as method parameters. Syntax: methodName(arrayType ... arrayReferenceName) Eg; public int addArray(int ... a) Alternative Syntax – Old versions of Java methodName(arrayType[] arrayReferenceName) Eg; public int addArray(int[] a)
Janaka Balasooriya CSE 110, Arizona State University Arrays as Method Parameters public class Sum { public int add(int x, int y) { return (x + y); } public int addArray(int ... a) { int total =0; for(int i =0 ; i<a.length ; i++) total += a[i]; return total; } } public class addNumbers { public static void main(String [] args) { int x =9, y = 8; int[] b = { 1, 2, 3, 4, 5}; Sum s1 = new Sum(); System.out.println( s1.add(x,y)); System.out.println(s1.addArray(b)); } }

This preview has intentionally blurred sections. Sign up to view the full version.

Janaka Balasooriya CSE 110, Arizona State University Homework: Not for Grading Problem: Design and implement the class “gradeCalculation” that determine a) Highest score b) Lowest score c) Class average
This is the end of the preview. Sign up to access the rest of the document.
• Fall '08
• KIM
• Subroutine, Phoenix, Arizona, Janaka Balasooriya

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern