Skip to content

Commit 8d942cc

Browse files
bowbahdoefirasrg
andauthored
Update (#53)
* more sections * First feedback round * Update prelude.md * ... * Spelling fix Co-Authored-By: Firas Regaieg <[email protected]> * Arguments chapter * More Challenges * Run prettier * user input * October 14th, #1 * Array challenges * Delete challenges * Null * ... * Update null_as_absence.md * Delete out.json * Fix quotes * Add first no_runs * Fix number example * ... * Write more of the classes section * Constructors * Clean up getting started a little * Use a duke * Don't link anywhere yet * Increase lines needed to show a duke * Fix field access section * ... * ... * ... * ... * ... * switch and enums * Update book.toml * Density * Update audience.md * .. * Strings 2 * Update length.md * Global Fields * Input * Update delayed_assignment.md * ... * ... * Update book.js * Update challenges.md * Remove blank Challenge * Fix some issues, push some incomplete sections * Update challenges.md * terminal * Update challenges.md * Switches and visibility * Growable array * Cli Args * Delete unused * Change url * inner classes * Update unchecked_exceptions.md * Update checked_exceptions.md * Update invariants.md * Packages * Records * Update the_default_package.md * Syntax highlighting wierdness * More records * Integers, Files, etc. * Move IOException around * ... * ... * Add new dukes and start hash maps * Start hashmap explanation * Objects * Update README.md * More object chapters * More hash maps * More hash maps * new section headers * Time types * ArrayList * For each loops * recursion * Arraylist recursion and switch * Switch progress --------- Co-authored-by: Firas Regaieg <[email protected]>
1 parent 61252b5 commit 8d942cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1524
-67
lines changed

.github/workflows/linter.yaml

+16-17
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@ name: Linter
33
on: [pull_request]
44

55
jobs:
6-
markdown-linter:
7-
name: "Markdown Linter"
8-
runs-on: ubuntu-latest
9-
steps:
10-
- uses: actions/checkout@v2
6+
# markdown-linter:
7+
# name: "Markdown Linter"
8+
# runs-on: ubuntu-latest
9+
# steps:
10+
# - uses: actions/checkout@v2
11+
# - name: markdownlint-cli
12+
# uses: nosborn/[email protected]
13+
# with:
14+
# files: .
15+
# config_file: .markdownlint.yaml
1116

12-
- name: markdownlint-cli
13-
uses: nosborn/[email protected]
14-
with:
15-
files: .
16-
config_file: .markdownlint.yaml
17-
18-
markdown-link-check:
19-
name: "Markdown Link Checker"
20-
runs-on: ubuntu-latest
21-
steps:
22-
- uses: actions/checkout@v2
23-
- uses: gaurav-nelson/[email protected]
17+
# markdown-link-check:
18+
# name: "Markdown Link Checker"
19+
# runs-on: ubuntu-latest
20+
# steps:
21+
# - uses: actions/checkout@v2
22+
# - uses: gaurav-nelson/[email protected]

README.md

+40-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,48 @@
33
[![codefactor](https://img.shields.io/codefactor/grade/github/together-java/modernjava)](https://www.codefactor.io/repository/github/together-java/modernjava)
44
[![license](https://img.shields.io/github/license/Together-Java/ModernJava)](https://github.com/Together-Java/ModernJava/blob/master/LICENSE)
55

6-
Book teaching how to write modern and effective Java. It is maintained by the community, anyone can contribute.
6+
Greetings.
7+
8+
This is a book intended to teach someone the Java language, from scratch.
9+
10+
You will find that the content makes heavy use of recently released and, for the moment,
11+
preview features. This is intentional as much of the topic ordering doesn't work
12+
without at least Java 21.
13+
14+
Right now I have several key areas where I could use some help:
15+
16+
* Writing Challenges. Most of the early sections have challenges students can do to test
17+
their understanding of the topics covered and for practice. I've shifted my focus away from
18+
these to make more progress on the main content of the book. Any assistance would be appreciated.
19+
* Theming. A lot of the chapters are...bland. Purely technical. I find that when I have the imagination to "theme" the subjects they become higher quality and more engaging overall. See
20+
an anime you liked recently and think you can make the math chapters use the characters from it?
21+
Give it a shot!
22+
* Fixing Mechanical Issues. I don't have an editor and I don't often proofread. If you find mechanical errors
23+
in my grammar or find issues with the way topics are ordered I would welcome fixes.
24+
25+
Notably I do not want to open the floodgates for contributions on the main chapter content
26+
just yet. This has the downside of slower progress but the upside of a more coherent result.
27+
28+
My primary goals with this are
29+
30+
* Get the ordering of topics right. By this I mean that every topic covered should have had its pre-requitsites covered in the topics previous. While "lesson 1: Inheritance" is clearly wrong
31+
in this regard, some things are more subtle.
32+
* Be a template for other people. This is a book. Not everyone likes books, some like youtube videos, some like over priced udemy courses, some attend College, etc. Everyone has different learning paths. I hope this to be of use to anyone looking to make a more up to date Java
33+
curriculum and hope that the vague order of things (which I consider superior to the content
34+
produced with the Java of years' past) as carried through.
35+
* Write as if the newest Java wasn't new. Its obvious when a book was written before Java 8
36+
because it always has newer additions with "addendum: brand new stuff in Java 8." But
37+
the order language features were introduced is hardly a good order to teach them. You have
38+
to pretend that Java 21 has always been *the* Java. Does it really make sense to show terrible
39+
C-style switch statements way before switch expressions?
40+
* Write as if the words Object Oriented Programming, Functional Programming, etc. didn't exist.
41+
While I understand that these all have definitions and are useful concepts to know about, introducing them early seems to lead to either dogma, rejection of said dogma, or some
42+
mix thereof. None of them are actually needed to understand the mechanics of and motivation
43+
behind what we would call "object oriented" or "functional" techniques. They certainly don't
44+
work as justification for adding getters and setters to every class.
745

846
Feel free to join our [discord server](https://discord.gg/together-java-272761734820003841)
9-
if you have any questions, or require assistance with the project. :relaxed:
47+
if you have any questions, or require assistance with the project.
1048

1149
## Getting started
1250

ferris.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,16 @@ function createFerris(type, size) {
5454
a.setAttribute('target', '_blank')
5555

5656
var toFileName = function (t) {
57-
return '../img/' + t.attr + '.svg';
57+
// return '../img/' + t.attr + '.svg';
58+
if (t.attr == 'panics') {
59+
return '../img/duke_armcross.webp'
60+
}
61+
else if (t.attr == 'does_not_compile') {
62+
return '../img/duke_computer.webp'
63+
}
64+
else if (t.attr == 'not_desired_behavior') {
65+
return '../img/duke_finger.webp'
66+
}
5867
}
5968

6069
var img = document.createElement('img')

src/SUMMARY.md

+89-47
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@
447447
- [Integer to a Base 16 String](./integers_ii/integer_to_a_base_16_string.md)
448448
- [Underscores in Integer Literals](./integers_ii/underscores_in_integer_literals.md)
449449

450+
- [🚧 Construction Zone 🚧]()
451+
450452
# Interactive Programs III
451453

452454
- [Files](./files.md)
@@ -456,76 +458,119 @@
456458
- [Write to a File](./files/write_to_a_file.md)
457459
- [Read from a File](./files/read_from_a_file.md)
458460
- [Create a Folder](./files/creating_a_folder.md)
459-
- [Delete a Folder](./files/creating_a_folder.md)
460-
- [Delete a File](./files/creating_a_folder.md)
461+
- [Delete a Folder](./files/deleting_a_folder.md)
462+
- [Delete a File](./files/deleting_a_file.md)
461463

462464
# Data Structures & Algorithms II
463465

464-
- [Hash Maps]()
465-
- [Hash Sets]()
466+
- [Hash Maps](./hash_maps.md)
467+
- [Filing Cabinets](./hash_maps/filing_cabinets.md)
468+
- [Hash Functions](./hash_maps/hash_functions.md)
469+
- [Function Range](./hash_maps/function_range.md)
470+
- [Buckets](./hash_maps/buckets.md)
471+
- [Hash Collision](./hash_maps/hash_collision.md)
472+
- [Hash Distribution](./hash_maps/hash_distribution.md)
473+
- [Growable Buckets](./hash_maps/growable_buckets.md)
474+
- [Keys and Values](./hash_maps/keys_and_values.md)
475+
- [Put Items](./hash_maps/put_items.md)
476+
- [Get Items](./hash_maps/get_items.md)
477+
466478

467479
# Code Structure IV
468480

481+
- [Object](./objects.md)
482+
- [Subtypes](./objects/subtypes.md)
483+
- [instanceof](./objects/instanceof.md)
484+
- [toString](./objects/toString.md)
485+
- [Override toString](./objects/override_toString.md)
486+
- [@Override](./objects/override.md)
487+
- [equals and hashCode](./objects/equals_and_hashCode.md)
488+
- [Override equals and hashCode](./objects/override_equals_and_hashCode.md)
489+
- [Variance and Casting](./objects/variance_and_casting.md)
490+
- [Subclasses](./objects/subclasses.md)
491+
- [Generics](./generics.md)
492+
- [Interfaces](./interfaces.md)
469493

470-
- [Interfaces]()
471-
- [@Override]()
472-
- [Generics]()
473-
- [Casting]()
474-
- [Object]()
475-
- [instanceof]()
476-
- [toString]()
477-
- [equals]()
478-
- [hashCode]()
479-
480-
481-
<!--
482-
483-
484-
485-
# Data Types IV
486-
487-
- [StringBuilder](./string_builder.md)
488-
- [Pattern]()
489-
490-
491-
# Concepts
494+
# Data Types V
492495

493-
- [The Idiot Game](./the_idiot_game.md)
496+
<!-- Note: Put a joke about the "A train leaves chicago at ..." problems.
497+
Make them do one. -->
498+
- [Time](./time.md)
499+
- [Instant](./time/instant.md)
500+
- [Duration](./time/duration.md)
501+
- [LocalDate](./time/local_date.md)
502+
- [LocalTime](./time/local_time.md)
503+
- [LocalDateTime](./time/local_date_time.md)
504+
- [ZonedDateTime](./time/zoned_date_time.md)
505+
- [OffsetDateTime](./time/offset_date_time.md)
506+
- [ArrayList](./array_list.md)
507+
- [Ubiquity](./array_list/ubiquity.md)
508+
- [Add an item](./array_list/add_an_item.md)
509+
- [Size](./array_list/size.md)
510+
- [Get an item](./array_list/get_an_item.md)
511+
- [Loop over items](./array_list/loop_over_items.md)
512+
- [Set an item](./array_list/set_an_item.md)
513+
- [Remove an item](./array_list/remove_an_item.md)
514+
- [HashMap](./hash_map.md)
515+
- [Multi-Dimensional Arrays](./multi_dimensional_arrays.md)
494516

495-
# Interactive Programs
517+
# Control Flow IV
518+
- [Loops III](./loops_iii.md)
519+
- [For-each loops]()
520+
- [Arrays]()
521+
- [Iterable]()
522+
- [ArrayList]()
523+
- [Reasons to go back]() <!-- -->
524+
- [Switch III](./switch_iii.md)
525+
- [Fallthrough](./switch_iii/fallthrough.md)
526+
- [break](./switch_iii/break.md)
527+
- [default](./switch_iii/default.md)
528+
- [return](./switch_iii/return.md)
529+
- [yield](./switch_iii/yield.md)
530+
- [Recursion](./recursion.md)
531+
- [Disclaimer](./recursion/disclaimer.md)
532+
- [Base Case](./recursion/base_case.md)
533+
- [Comparison to Delegation](./recursion/comparison_to_delegation.md)
534+
- [Comparison to Loops](./recursion/comparison_to_loops.md)
496535

536+
# Code Structure V
537+
- [Class Extension](./class_extension.md)
538+
- [Abstract Classes](./abstract_classes.md)
497539

498-
# The Computing Environment
540+
# Concepts II
499541

542+
- [Encapsulation](./encapsulation.md)
543+
- [Methods]()
544+
- [Classes]()
545+
- [Information Hiding]()
500546

547+
# Building
501548

549+
- [Compilation]()
550+
- [Compile Java Code]()
551+
- [Compile a List of Files]()
552+
- [Specify Where to Find Sources]()
553+
- [Enable Debug Info]()
502554

555+
# Data Types VI
556+
- [StringBuilder]()
557+
- [Pattern]()
503558

504-
# Interactive Programs
559+
<!--
505560
506561
507-
- [Command Line Arguments]()
508562
509-
# Code Structure IV
510563
564+
# Concepts
511565
512-
- [Import]()
513-
- [Packages]()
514-
- [Public]()
515-
- [Package Private]()
516-
566+
- [The Idiot Game](./the_idiot_game.md)
517567
518568
# Data Types V
519569
520570
- [Strings III]()
521571
- [StringBuilder](./stringbuilder.md)
522572
- [Regular Expressions]()
523573
524-
# Code Structure V
525-
526-
- [toString]()
527-
- [Interfaces]()
528-
- [@Override]()
529574
530575
531576
# Code Structure V
@@ -535,6 +580,8 @@
535580
- [Safety]()
536581
- [Unsafe Casts]()
537582
583+
[Informal Diagrams]
584+
538585
# Data Types VI
539586
540587
- [Integers II]()
@@ -546,7 +593,6 @@
546593
- [Add an item]()
547594
- [Get an item]()
548595
- [Set an item]()
549-
- [Loop over Contents]()
550596
551597
# Control Flow IV
552598
@@ -564,10 +610,6 @@
564610
- [Sets]()
565611
- [HashSet]()
566612
567-
# Interactive Programs II
568-
569-
- [Files]()
570-
571613
# Metaprogramming
572614
573615
- [Reflection]()

src/abstract_classes.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Abstract Classes

src/array_list.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# ArrayList
2+
3+
Java comes with a generic growable array. It is called
4+
an `ArrayList`.
5+
6+
```java
7+
import java.util.ArrayList;
8+
9+
void main() {
10+
ArrayList<String> names = new ArrayList<>();
11+
names.add("John Wick");
12+
13+
System.out.println(names);
14+
}
15+
```

src/array_list/add_an_item.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Add an item
2+
3+
To add an item to an `ArrayList` you use the `.add`
4+
method.
5+
6+
```java
7+
import java.util.ArrayList;
8+
9+
void main() {
10+
ArrayList<String> names = new ArrayList<>();
11+
names.add("The Bowery King");
12+
names.add("Caine");
13+
14+
System.out.println(names);
15+
}
16+
```
17+
18+
The way this works is conceptually the
19+
same as the growable array that we went over earlier.
20+
21+
All you need to know though is that you can add
22+
as many items as you will and the container will grow
23+
dynamically.

src/array_list/get_an_item.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Get an item
2+
3+
To get an item at a given index in an `ArrayList`
4+
you should use `.get`
5+
6+
```java
7+
import java.util.ArrayList;
8+
9+
void main() {
10+
ArrayList<String> names = new ArrayList<>();
11+
names.add("Winston Scott");
12+
13+
String name = names.get(0);
14+
System.out.println(name);
15+
}
16+
```
17+
18+
If the index you picked is greater than the number of elements in the `ArrayList`
19+
it will throw an `IndexOutOfBoundsException`
20+
21+
```java,panics
22+
import java.util.ArrayList;
23+
24+
void main() {
25+
ArrayList<String> names = new ArrayList<>();
26+
names.add("Killa Harkan");
27+
28+
String name = names.get(10);
29+
System.out.println(name);
30+
}
31+
```

0 commit comments

Comments
 (0)