mirror of
https://github.com/Brandon-Rozek/website.git
synced 2025-10-10 15:01:15 +00:00
Website snapshot
This commit is contained in:
parent
ee0ab66d73
commit
50ec3688a5
281 changed files with 21066 additions and 0 deletions
32
content/ta/spring2018/cpsc220/mar20.md
Normal file
32
content/ta/spring2018/cpsc220/mar20.md
Normal file
|
@ -0,0 +1,32 @@
|
|||
# Lecture for March 20th
|
||||
|
||||
## Unit Testing
|
||||
|
||||
With unit testing you are able to test small parts as you go. With unit testing, you can test many examples and border cases (extreme inputs) to see how your code reacts to different input.
|
||||
|
||||
## Variable Scope
|
||||
|
||||
A variable declared inside a method is only accessible inside that method.
|
||||
|
||||
A good rule of thumb is that if a variable is declared within curly braces {} then it does not exist outside that curly brace.
|
||||
|
||||
## Method Overloading
|
||||
|
||||
Sometimes we need to have methods with the same name but different input parameters.
|
||||
|
||||
```java
|
||||
public static int multiply(int a, int b) {
|
||||
return a * b;
|
||||
}
|
||||
```
|
||||
|
||||
This method only works with integers, what if we want to multiply two doubles?
|
||||
|
||||
We can overload the method by declaring another method with the same name.
|
||||
|
||||
```java
|
||||
public static double multiply(double a, double b) {
|
||||
return a * b;
|
||||
}
|
||||
```
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue