CSE 8B Lecture Notes - Lecture 10: Object Copying

59 views3 pages

Document Summary

@override public boolean equals(object o) { if(this instanceof o) { // return true if same, false otherwise return false; Recursion public static void foo(int x) { if(x > 1) foo(x 1); This recursive code will print out the numbers starting at 1 all the way to x public static void foo(int x) { This recursive code will print out the numbers starting at x all the way down to 1 public static int factorial(int n) { if(n <= 1) return 1; return n * factorial(n 1); This code find the factorial of a number n public static int search(double[] array, double tofind, int lastpos){ // base case 1 if last element is one we want, return its index if(array[lastpos] == tofind) return lastpos; // base case 2 else if last element is not one we want and there are. // no more to look at else if(lastpos == 0) return -1;

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