/* This is a primitive */
int x = 127;
/* This is a reference */
String s = new String("Hello");
graph TD
A[x: 127]
B[s] --> C("Hello")
/* This is an array */
int[] x = {5,7,8};
graph LR
B[x] --> C(5,7,8)
/* What do you think this does? */
Date date1 = new Date(2018, 6, 14);
Date date2 = new Date(2018, 6, 14);
if(date1 == date2){
System.out.println("They are the same!");
}
/* These two vars are NOT == */
Date date1 = new Date(2018, 6, 14);
Date date2 = new Date(2018, 6, 14);
if(date1 == date2){
System.out.println("They are the same!");
}
graph LR
A[date1] --> B(6-14-2018)
C[date2] --> D(6-14-2018)
/* These two vars are NOT == */
Date date1 = new Date(2018, 6, 14);
Date date2 = new Date(2018, 6, 14);
/* Use .equals() to compare references */
if(date1.equals(date2)){
System.out.println("They are the same!");
}
graph LR
A[date1] --> B(6-14-2018)
C[date2] --> D(6-14-2018)
Date date1 = new Date(2018, 6, 14);
Date date2 = new Date(2018, 7, 18);
date1 = date2;
System.out.println(date1);
Date date1 = new Date(2018, 6, 14);
Date date2 = new Date(2018, 7, 18);
date1 = date2;
System.out.println(date1);
Date date1 = new Date(2018, 6, 14);
Date date2 = new Date(2018, 7, 18);
date1 = date2;
System.out.println(date1);
/* From previous slide */
/* Note that BOTH date1 and date2 are changed */
date1.setYear(2017)
graph TD
B(6-14-2018)
A[date1] --> D
C[date2] --> D(7-18-2017)
/* From previous slide */
/* Note that date1 is not affected here */
date2 = new Date(2013, 10, 28);
graph TD
B(6-14-2018)
A[date1] --> D(7-18-2017)
C[date2] --> E(10-28-2013)
Click the center of the target
Close window