9
9
// ## Types
10
10
// A primitive type is stored as value while an object is stored as
11
11
// a reference (the address of the object in memory).
12
- // In Java, `var` create a new variable
12
+ // In Java, `var` creates a new variable
13
13
var maxIntensity = 1.0 ; // it's a value
14
14
var colorName = "black" ; // it's a reference to String somewhere in memory
15
15
@@ -35,8 +35,8 @@ System.out.println("the value of colorName is " + colorName);
35
35
record Light (String color , double intensity ) {}
36
36
37
37
// ### Object creation with `new`
38
- // To create an object in memory, we use the operator `new` followed by the value of each record components
39
- // the following instruction create a Light with "blue" as color and 1.0 as intensity.
38
+ // To create an object in memory, we use the operator `new` followed by the value of each record component.
39
+ // The following instruction creates a Light with "blue" as color and 1.0 as intensity.
40
40
var blueLight = new Light ("blue" , 1.0 );
41
41
System .out .println (blueLight );
42
42
@@ -58,7 +58,7 @@ System.out.println(blueLight.toString());
58
58
System .out .println (blueLight );
59
59
60
60
// ### equals()
61
- // In Java, you can ask if two objects are equals , using the method equals(Object).
61
+ // In Java, you can ask if two objects are equal , using the method equals(Object).
62
62
// The return value is a boolean (a primitive type that is either true or false).
63
63
var redLight = new Light ("red" , 0.5 );
64
64
var redLight2 = new Light ("red" , 0.5 );
@@ -83,4 +83,4 @@ System.out.println(greenLight2.hashCode());
83
83
// call on an object using the operator `.`.
84
84
// A Record defines methods to access the value of a component, and also
85
85
// `toString()` to get the textual representation of an object and
86
- // `equals()` and `hashCode()` to test if two objects are equals .
86
+ // `equals()` and `hashCode()` to test if two objects are equal .
0 commit comments