COMPSCI 2S03 Lecture Notes - Lecture 17: State Diagram

65 views2 pages

Document Summary

Lecture 17 b1 = a1 + b1; ay[i] = ax; for (int i = 0; i <= ax. length(); i++) { a = 10; = 5; adda(a, b); int x[] = new int[5]; addb(x, y); void adda(int a, nt b) { void addb(int[] ax, int[] ay) { What happens in the main method? a = 10; Executes subprogram adda(int a1, int b1) a1 and b1 are the values passed to the method, but the values of a and b are still 10 and 5 in the main program. All primitive data types only pass by value! Not the reference in the memory location, they pass the actual value. To pass by reference, you must create an object. To get the new value, you need to return a new value and assign it to the variable. int adda(int a, nt b) { Now b is equal to adda result (15). You cannot return multiple values in java. return a1 + b1;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions