COMP 202 Lecture Notes - Lecture 38: Control Flow, Null Pointer, Negative Number

58 views5 pages
jc123 and 40170 others unlocked
COMP 202 Full Course Notes
100
COMP 202 Full Course Notes
Verified Note
100 documents

Document Summary

Final keyword final int[] a = {1, 2, 3}; a[0] = 15; a = new int[5]; This works because final ensures that the address doesn"t change (address = value of the array). The following would be changing the address and would thus give a compile error: A method in java is overloaded if there is more than one method with the same name in the same class. Note: two methods with the same name in different classes are not overloaded. In order to do this, you must give the method different inputs. When an overloaded method is called, the compiler matches on the input types to figure out which version to use. Most useful with constructors: as soon as you have more than one constructor, it"s overloaded. This is because you can"t choose the name of your constructor. As soon as you create a constructor, you lose access to the default constructor. Example public static void method(int x, int y)

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