CS 145 Lecture 16 – Shortcircuiting and Truthtables
Agenda
- what ?s
- short circuiting
- truthtables
TODO
- Read section 4.1. On a 1/4 sheet, share four thoughts: questions, observations, or sightings of conditional logic in your life.
Code
Trick.java
package lecture1008;
public class Trick {
public static boolean getTrue() {
System.out.print("t");
return true;
}
public static boolean getFalse() {
System.out.print("f");
return false;
}
public static void main(String[] args) {
boolean trash = getFalse() || getFalse();
}
}
CheckT.java
package lecture1008;
public class CheckT {
public static void main(String[] args) {
String s = "letter";
System.out.println(s.length() > 3 && s.charAt(2) == 't');
}
}
Haiku
on false dichotomies:
The two roads diverged
Completionist me took both
There was a save point
The two roads diverged
Completionist me took both
There was a save point