CSE116 / CSE504 Introduction to Computer Science II Dr. Carl Alphonce

advertisement
CSE116 / CSE504
Introduction to Computer Science II
Dr. Carl Alphonce
343 Davis Hall
alphonce@buffalo.edu
Office hours:
Thursday 12:00 PM – 2:00 PM
Friday 8:30 AM – 10:30 AM
OR request appointment via e-mail
PROFESSIONALISM
Turn off and put away electronics:
cell phones
pagers
laptops
tablets
etc.
© Dr. Carl Alphonce
EXAM 1 NOTICE
DATE: Tuesday March 8
TIME: 9:15 PM – 10:15 PM
LOCATION: various rooms in NSC
specific room/seat assignments to come
COVERAGE:
material up to and including 2/26
HAVE A CONFLICT?
I will ask for documentation 2/22 – 2/26
BRING: your UB card
NO ELECTRONICS: cell phone, calculator, etc.
© Dr. Carl Alphonce
ANNOUNCEMENTS
Sign up for Piazza (up to 97% registration)
10 students have still not signed up
piazza.com/buffalo/spring2016/cse116
Recitation
Write-ups are running this week
ROADMAP
Last class
defining the MultiSet
Today
common problems
defining the MultiSet
Coming up
defining the MultiSet
channel 1
What is printed?
int x = 5;
int y = x++;
System.out.println("x: "+x+" y: "+y);
A.
B.
C.
D.
x:5y:5
x:5y:6
x:6y:5
x:6y:6
What is printed?
int x = 5;
int y = x++;
System.out.println("x: "+x+" y: "+y);
A.
B.
C.
D.
x:5y:5
x:5y:6
x:6y:5
x:6y:6
What is printed?
int x = 5;
int y = x++;
System.out.println("x: "+x+" y: "+y);
A.
B.
C.
D.
x:5y:5
x:5y:6
x:6y:5
x:6y:6
Explanation
What is printed?
int x = 5;
int y = x++;
System.out.println("x: "+x+" y: "+y);
x++isanexpression.
Thereforeithasavalue.
int x = 5;
int y = x;
x = x + 1;
accessthenincrement:“POSTincrement”operator
OUTPUT
x:6y:5
Expanding…
What is printed?
int x = 5;
int y = x++;
++x;
System.out.println("x: "+x+" y: "+y);
++xisanexpression.
Thereforeithasavalue.
int x = 5;
x = x + 1;
int y = x;
incrementthenaccess:“PREincrement”operator
OUTPUT
x:6y:6
public boolean remove(Object obj)
(see code in repo)
© Dr. Carl Alphonce
Download