Skip to content

Commit 9aa0b3c

Browse files
committed
Update other prints
1 parent 76b013a commit 9aa0b3c

27 files changed

+79
-44
lines changed

src/SUMMARY.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,14 +706,27 @@ Make them do one. -->
706706
- [Lambdas](./lambdas.md)
707707
- [Functional Interfaces](./lambdas/functional_interfaces.md)
708708
- [@FunctionalInterface](./lambdas/functional_interface_annotation.md)
709-
- [Streams]()
709+
- [Lambda Expressions](./lambdas/lambda_expressions.md)
710+
- [Method References](./lambdas/method_references.md)
711+
- [Runnable]()
712+
- [Function]()
713+
- [Relation to Checked Exceptions]()
714+
- [Streams](./streams.md)
715+
- [map](./streams/map.md)
716+
- [filter](./streams/filter.md)
717+
- [Collectors](./streams/collectors.md)
718+
- [toList](./streams/toList.md)
719+
- [mapMulti](./streams/mapMulti.md)
720+
- [Gatherers](./streams/gatherers.md)
710721

711722
# Sharing Code
712723

713724
- [Compilation](./compilation.md)
714725
- [javac]()
726+
- [--release]()
715727
- [Packaging]()
716728
- [jar]()
729+
- [--main-class]()
717730
- [Documentation]()
718731
- [javadoc]()
719732
- [Documentation Comments](./documentation/documentation_comments.md)
@@ -1002,6 +1015,18 @@ jshell
10021015
10031016
The You of today is not the you of tommorow
10041017
1018+
1019+
Separate a mobile number given in an international format into parts countrycode, number
1020+
I think its a nice example about a problem which can be solved in a number of ways, and still being very precise and compact in description
1021+
mikamoilanen — 3:53 PM
1022+
Start with a list of few countrycodes, like +1, +358
1023+
Given a phone number eg "+358451252855", separate it into two parts: +358 and 451252855
1024+
The essiest way is to sort country codes by lenght, longest first, and loop through them by asking if the phonenumber.startsWith(cc)
1025+
(this works as codes are common-prefix-free)
1026+
mikamoilanen — 4:01 PM
1027+
Another solution creates a nice opportunity to introduce creating your own datastructure for more efficient solution: Build a tree out of the codes, where each number has N childs, and traverse throught that tree number-by-number of the phonenumber
1028+
THEN you could even introduce packing the data as bitvectors in order to have even more compact data structure
1029+
10051030
-->
10061031

10071032

src/annotations/reflective_access.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class Main {
1818

1919
Field[] fields = drinkClass.getFields();
2020
for (var field : fields) {
21-
System.out.print(field.getName());
22-
System.out.print(" - ");
21+
IO.print(field.getName());
22+
IO.print(" - ");
2323

2424
Special annotationValue = field.getAnnotation(Special.class);
2525
if (annotationValue == null) {

src/arguments/challenges.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ Call the defined methods in a way that outputs "I did it!"
7474

7575
```java,editable
7676
void i() {
77-
System.out.print("I");
77+
IO.print("I");
7878
}
7979
8080
void did(String what) {
8181
IO.println("did " + what);
8282
}
8383
8484
void space() {
85-
System.out.print(" ");
85+
IO.print(" ");
8686
}
8787
8888
void main() {

src/constructors/overloads.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ class Muppet {
4040
}
4141

4242
void announce(Muppet muppet) {
43-
System.out.print(muppet.name);
43+
IO.print(muppet.name);
4444
if (muppet.talented) {
45-
System.out.print(" is ");
45+
IO.print(" is ");
4646
}
4747
else {
48-
System.out.print(" is not ");
48+
IO.print(" is not ");
4949
}
5050
IO.println("talented.");
5151
}

src/first_steps.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ This bit of magic here - `IO.println` - is a "statement" that "prints" the text
3434

3535
**print** with new **l**i**n**e.
3636

37-
If you were to replace it with `System.out.print`, then the output would lack that new line. This makes the following program be functionally identical to the first.
37+
If you were to replace it with `IO.print`, then the output would lack that new line. This makes the following program be functionally identical to the first.
3838

3939
```java
4040
~void main() {
41-
System.out.print("Hello, ");
42-
System.out.print("World");
41+
IO.print("Hello, ");
42+
IO.print("World");
4343
IO.println("!");
4444
~}
4545
```
@@ -48,8 +48,8 @@ Which, when we add back `void main()`, looks like this.
4848

4949
```java
5050
void main() {
51-
System.out.print("Hello, ");
52-
System.out.print("World");
51+
IO.print("Hello, ");
52+
IO.print("World");
5353
IO.println("!");
5454
}
5555
```

src/first_steps/semicolon.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The `;` at the end of each of those lines is a "semicolon".
44

55
```java
66
~void main(){
7-
System.out.print("Hello, "); // <-- this thing
7+
IO.print("Hello, "); // <-- this thing
88
// ^
99
~}
1010
```
@@ -15,7 +15,7 @@ more complicated than these examples.
1515

1616
```java
1717
~void main(){
18-
System.out.print(
18+
IO.print(
1919
"Hello, "
2020
);
2121
~}
@@ -29,7 +29,7 @@ If you happen to have an extra semi-colon or two that is technically okay. It ju
2929

3030
```java
3131
~void main() {
32-
System.out.print(
32+
IO.print(
3333
"Hello, "
3434
);;
3535
~}
@@ -39,7 +39,7 @@ Or even
3939

4040
```java
4141
~void main() {
42-
System.out.print(
42+
IO.print(
4343
"Hello, "
4444
);
4545

src/instance_methods/clarity.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class Elmo {
1212

1313
void sayHello() {
1414
IO.println("Hi, I'm Elmo");
15-
System.out.print("I am ");
16-
System.out.print(this.age);
15+
IO.print("I am ");
16+
IO.print(this.age);
1717
IO.println(" years old.");
1818
}
1919
}

src/instance_methods/field_access.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ class Elmo {
99

1010
void sayHello() {
1111
IO.println("Hi, I'm Elmo");
12-
System.out.print("I am ");
12+
IO.print("I am ");
1313

1414
// You can use elmo's age by just writing "age"
15-
System.out.print(age);
15+
IO.print(age);
1616
IO.println(" years old.");
1717
}
1818
}

src/instance_methods/field_updates.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class Elmo {
99

1010
void sayHello() {
1111
IO.println("Hi, I'm Elmo");
12-
System.out.print("I am ");
13-
System.out.print(age);
12+
IO.print("I am ");
13+
IO.print(age);
1414
IO.println(" years old.");
1515
}
1616

src/instance_methods/invoke_other_methods.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class Elmo {
99

1010
void sayHello() {
1111
IO.println("Hi, I'm Elmo");
12-
System.out.print("I am ");
13-
System.out.print(age);
12+
IO.print("I am ");
13+
IO.print(age);
1414
IO.println(" years old.");
1515
}
1616

0 commit comments

Comments
 (0)