CS 145 Lecture 4 – Types
September 10, 2014 by Chris Johnson. Filed under cs145, fall 2014, lectures.
Agenda
- what ?s
- lab impressions
- office hours
- what’s wrong with this
- types
- switching types
What’s Wrong With This
int a = 5;
int b = 6;
int a = 7;
show
System.out.println("I'm ", 5);
show
- show
Code
Declassignments.java
package lecture0910;
public class Declassignments {
public static void main(String[] args) {
// int a;
// System.out.println(a);
// System.out.printf("I'm %d", 5);
System.out.println('\u265b');
System.out.println('\u2603');
System.out.println('\u2672');
System.out.println('\u2697');
System.out.println('\u266A');
System.out.println('\u2682');
byte b = 127;
short s = b;
b = (byte) s;
int i = (int) (100 * 0.5);
System.out.println(i);
}
}
Haiku
on the authoritarian forcing of types:
My dog was meowing
The vet put him in a cast
Now he barks with tears
show