You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: concepts/basics/introduction.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
# Introduction
2
2
3
-
Java is a statically-typed language, which means that everything has a type at compile-time. Assigning a value to a name is referred to as defining a variable. A variable is defined by explicitly specifying its type.
3
+
Java is a statically-typed language, which means that the type of a variable is known at compile-time. Assigning a value to a name is referred to as defining a variable. A variable is defined by explicitly specifying its type.
4
4
5
5
```java
6
6
int explicitVar =10;
7
7
```
8
8
9
-
Updating a variable's value is done through the `=` operator. Once defined, a variable's type can never change.
9
+
Updating a variable's value is done through the `=` operator. Here, `=` does not represent mathematical equality. It simply assigns a value to a variable. Once defined, a variable's type can never change.
10
10
11
11
```java
12
12
int count =1; // Assign initial value
13
13
count =2; // Update to new value
14
14
15
-
// Compiler error when assigning different type
15
+
// Compiler error when assigning a different type
16
16
// count = false;
17
17
```
18
18
@@ -24,7 +24,7 @@ class Calculator {
24
24
}
25
25
```
26
26
27
-
A function within a class is referred to as a _method_. Each method can have zero or more parameters. All parameters must be explicitly typed, there is no type inference for parameters. Similarly, the return type must also be made explicit. Values are returned from functions using the `return` keyword. To allow a method to be called by other classes, the `public` access modifier must be added.
27
+
A function within a class is referred to as a _method_. Each method can have zero or more parameters. All parameters must be explicitly typed, there is no type inference for parameters. Similarly, the return type must also be made explicit. Values are returned from methods using the `return` keyword. To allow a method to be called by other classes, the `public` access modifier must be added.
28
28
29
29
```java
30
30
classCalculator {
@@ -34,10 +34,10 @@ class Calculator {
34
34
}
35
35
```
36
36
37
-
Invoking a method is done by specifying its class and method name and passing arguments for each of the method's parameters.
37
+
Invoking/calling a method is done by specifying its class and method name and passing arguments for each of the method's parameters.
38
38
39
39
```java
40
-
int sum =newCalculator().add(1, 2);
40
+
int sum =newCalculator().add(1, 2);// here the "add" method has been called to perform the task of addition
41
41
```
42
42
43
43
Scope in Java is defined between the `{` and `}` characters.
Implement the (_static_) `AnnalynsInfiltration.canFreePrisoner()` method that takes four boolean values. The first three parameters indicate if the knight, archer and the prisoner, respectively, are awake. The last parameter indicates if Annalyn's pet dog is present. The method returns `true` if the prisoner can be freed based on the state of the three characters and Annalyn's pet dog presence. Otherwise, it returns `false`:
56
+
Implement the (_static_) `AnnalynsInfiltration.canFreePrisoner()` method that takes four boolean values. The first three parameters indicate if the knight, archer and the prisoner, respectively, are awake. The last parameter indicates if Annalyn's pet dog is present. The method returns `true` if the prisoner can be freed based on the state of the three characters and Annalyn's pet dog's presence. Otherwise, it returns `false`:
0 commit comments