Skip to content

Update main #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 76 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
2393236
more sections
bowbahdoe May 8, 2023
25924c1
First feedback round
bowbahdoe May 8, 2023
8503233
Update prelude.md
bowbahdoe May 8, 2023
914cd82
...
bowbahdoe May 13, 2023
ff8df0d
Spelling fix
bowbahdoe Jun 9, 2023
9c2678a
Arguments chapter
bowbahdoe Jun 17, 2023
f08cd22
More Challenges
bowbahdoe Jun 25, 2023
f751c08
Run prettier
bowbahdoe Aug 28, 2023
43ea470
user input
bowbahdoe Aug 28, 2023
794c9a0
October 14th, #1
bowbahdoe Oct 14, 2023
2642397
Array challenges
bowbahdoe Oct 14, 2023
94d3205
Delete challenges
bowbahdoe Oct 14, 2023
d7941e7
Null
bowbahdoe Oct 15, 2023
beafad8
...
bowbahdoe Oct 15, 2023
72693cc
Update null_as_absence.md
bowbahdoe Oct 15, 2023
33d0edc
Merge remote-tracking branch 'upstream/develop' into develop
bowbahdoe Nov 19, 2023
9a4b031
Delete out.json
bowbahdoe Nov 19, 2023
d2d6930
Fix quotes
bowbahdoe Nov 19, 2023
adc4811
Add first no_runs
bowbahdoe Nov 19, 2023
91ba156
Fix number example
bowbahdoe Nov 19, 2023
a07e987
...
bowbahdoe Feb 5, 2024
c90c905
Write more of the classes section
bowbahdoe Feb 6, 2024
1fd9a4d
Constructors
bowbahdoe Feb 7, 2024
d4a9dda
Clean up getting started a little
bowbahdoe Feb 7, 2024
62e73ad
Use a duke
bowbahdoe Feb 7, 2024
53cb45b
Don't link anywhere yet
bowbahdoe Feb 7, 2024
cc6cb4f
Increase lines needed to show a duke
bowbahdoe Feb 7, 2024
47627e5
Fix field access section
bowbahdoe Feb 7, 2024
161f934
...
bowbahdoe Feb 7, 2024
fcf44de
...
bowbahdoe Feb 7, 2024
b50a63f
...
bowbahdoe Feb 7, 2024
5067aec
...
bowbahdoe Feb 7, 2024
b455ef1
...
bowbahdoe Feb 7, 2024
e808fdf
switch and enums
bowbahdoe Feb 12, 2024
517973d
Merge remote-tracking branch 'upstream/develop' into develop
bowbahdoe Feb 13, 2024
344512f
Merge remote-tracking branch 'upstream/develop' into develop
bowbahdoe Feb 14, 2024
ed4ee40
Merge remote-tracking branch 'upstream/develop' into develop
bowbahdoe Feb 14, 2024
c0aaf10
Update book.toml
bowbahdoe Feb 14, 2024
cb7b4eb
Density
bowbahdoe Feb 14, 2024
7fd3e45
Update audience.md
bowbahdoe Feb 14, 2024
fdfb5bc
..
bowbahdoe Feb 14, 2024
c8bcf9d
Strings 2
bowbahdoe Feb 14, 2024
eeb4080
Update length.md
bowbahdoe Feb 14, 2024
72ba7e8
Global Fields
bowbahdoe Feb 15, 2024
b4f83e4
Merge remote-tracking branch 'upstream/develop' into develop
bowbahdoe Feb 17, 2024
9899b02
Merge remote-tracking branch 'upstream/develop' into develop
bowbahdoe Feb 17, 2024
e92020a
Input
bowbahdoe Feb 20, 2024
6376800
Update delayed_assignment.md
bowbahdoe Feb 20, 2024
f2d3d2e
...
bowbahdoe Feb 20, 2024
63a2973
...
bowbahdoe Feb 20, 2024
a27e061
Update book.js
bowbahdoe Apr 10, 2024
dc30eb5
Update challenges.md
bowbahdoe Apr 27, 2024
3b857c0
Remove blank Challenge
bowbahdoe Apr 28, 2024
521828f
Fix some issues, push some incomplete sections
bowbahdoe Apr 28, 2024
4457dee
Update challenges.md
bowbahdoe May 7, 2024
be25314
terminal
bowbahdoe May 7, 2024
5a02f25
Update challenges.md
bowbahdoe May 15, 2024
02fa7d6
Switches and visibility
bowbahdoe Jun 18, 2024
2d9ef2c
Growable array
bowbahdoe Jun 18, 2024
62f5d6b
Cli Args
bowbahdoe Jun 18, 2024
620427e
Delete unused
bowbahdoe Jun 18, 2024
7cd05e2
Change url
bowbahdoe Jun 19, 2024
cba4baa
inner classes
bowbahdoe Jun 19, 2024
898c891
Update unchecked_exceptions.md
bowbahdoe Jun 19, 2024
da1ec01
Update checked_exceptions.md
bowbahdoe Jun 19, 2024
d5e9fc1
Update invariants.md
bowbahdoe Jun 19, 2024
04bec4e
Packages
bowbahdoe Jun 20, 2024
02de34b
Records
bowbahdoe Jun 20, 2024
84b78fd
Update the_default_package.md
bowbahdoe Jun 20, 2024
e028ff7
Syntax highlighting wierdness
bowbahdoe Jun 20, 2024
b13d2dc
More records
bowbahdoe Jun 21, 2024
90beb94
Integers, Files, etc.
bowbahdoe Jun 25, 2024
c80e1f4
Move IOException around
bowbahdoe Jun 25, 2024
5a8d5fb
...
bowbahdoe Jun 25, 2024
4452c6a
Merge branch 'Together-Java:develop' into develop
bowbahdoe Jun 26, 2024
cb6e65b
...
bowbahdoe Jun 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Write more of the classes section
  • Loading branch information
bowbahdoe committed Feb 6, 2024
commit c90c9059f6db7e714fd5b1f93f001d4d4918cb9e
10 changes: 0 additions & 10 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ additional-js = ["ferris.js"]
enable = true # whether or not to enable section folding
level = 0 # the depth to start folding

[preprocessor.features]
command = "python3 features.py"
# Going to start writing the rest of the book
# Assuming this is true
toplevel_anonymous_class = true
# Not ready
simple_io = false
# Turn on when Java 21 released
java_21 = false

[output.html.playground]
editable = true

Expand Down
56 changes: 0 additions & 56 deletions features.py

This file was deleted.

61 changes: 34 additions & 27 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,26 +180,23 @@
- [Inferred Types](./arguments/inferred_types.md)
- [Challenges](./arguments/challenges.md)

- [Return](./return_values.md)
- [Return Values](./return_values/return_values.md)
- [Conversion](./return_values/conversion.md)
- [Return Values](./return_values.md)
- [Declaration](./return_values/declaration.md)
- [Return Statement](./return_values/return_statement.md)
- [Exhaustiveness](./return_values/exhaustiveness.md)
- [void](./return_values/void.md)
- [Return in void methods](./return_values/return_in_void_methods.md)
- [Conversion](./return_values/conversion.md)
- [Unreachable Statements](./return_values/unreachable_statements.md)
- [Pure Functions](./return_values/pure_functions.md)
- [Impure Functions](./return_values/impure_functions.md)

# Data Types III

- [Identity Types](./identity_types.md)
- [Comparison with ==](./identity_types/comparison_with_equalsequals.md)
- [Primitive Types](./primitive_types.md)
- [null](./null.md)
- [Null as Absence](./null/null_as_absence.md)
- [Null as Unknown](./null/null_as_unknown.md)
- [Checking for null](./null/checking_for_null.md)
- [Field Access](./null/field_access.md)
- [Instance Methods](./null/instance_methods.md)
- [NullPointerException](./null/null_pointer_exception.md)
- [Boxed Primitives](./boxed_primitives.md)
- [Primitive Types](./boxed_primitives/primitive_types.md)
- [Integer](./boxed_primitives/integer.md)
- [Double](./boxed_primitives/double.md)
- [Character](./boxed_primitives/character.md)
Expand All @@ -209,38 +206,48 @@
- [Arrays of Boxed Primitives](./boxed_primitives/arrays_of_boxed_primitives.md)
- [Challenges](./boxed_primitives/challenges.md)
- [Arrays II](./arrays_ii.md)
- [Initializion with Size](./arrays_ii/initialization_with_size.md)
- [Default Values](./arrays_ii/default_values.md)
- [Populate Array]()
- [Populate Arrays](./arrays_ii/populate_arrays.md)

# Code Structure II

- [Classes](./classes.md)

- [The meaning of the word Class](./classes/the_meaning_of_the_word_class.md)
- [Class Declaration](./classes/class_declaration.md)
- [User Defined Types](./classes/user_defined_types.md)
- [Naming Classes](./classes/naming_classes.md)
- [Field Declaration](./classes/field_declaration.md)
- [Field Access](./classes/field_access)
- [Naming Fields](./classes/naming_fields.md)
- [new](./classes/new.md)
- [Zero Values](./classes/zero_values.md)
- [Instances](./classes/instances.md)
- [Fields](./classes/fields.md)
- [Field Initialization](./classes/field_initialization.md)
- [Field Access](./classes/field_access.md)
- [Field Default Values](./classes/field_default_values.md)
- [Aliasing](./classes/aliasing.md)
- [null](./classes/null.md)
- [Return Multiple Values](./classes/return_multiple_values.md)

- [Constructors](./constructors.md)
- [Instance Methods](./instance_methods.md)
- [Invocation](./instance_methods/invocation.md)
- [this](./instance_methods/this.md)
- [Aliasing](./instance_methods/aliasing.md)
- [Derived Values](./instance_methods/derived_values.md)

## Control Flow III
- [Exceptions]()
- [Recursion]()

## Code Structure III
- [Constructors](./constructors.md)
- [this](./constructors/this.md)
- [The Default Constructor](./constructors/the_default_constructor.md)
- [Final Fields](./constructors/final_fields.md)
- [Multiple Constructors](./constructors/multiple_constructors.md)
- [Invariants]()
- [Multiple Files]()
- [The Implicit Main Class]()
- [Private]()

## Data Types IV

- [Instance Methods](./instance_methods.md)

- [Declaration](./instance_methods/declaration.md)
- [Invocation](./instance_methods/invocation.md)
- [this](./instance_methods/this.md)
- [Aliasing](./instance_methods/aliasing.md)
- [Derived Values](./instance_methods/derived_values.md)

- [Documentation]()
- [Documentation Comments]()
Expand Down
4 changes: 2 additions & 2 deletions src/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Arrays are used to represent a fixed-size collection of things.

```java
```java,no_run
int[] oddNumbers = { 1, 3, 5, 7, 9 };
```

Expand All @@ -14,7 +14,7 @@ We call the things stored in an array its "elements."
You can make an array of any type of element by using the name of the type followed by
`[]`.

```java
```java,no_run
char[] letters = { 'a', 'b', 'c' };
String[] words = { "its", "as", "easy", "as" }
int[] numbers = { 1, 2, 3 };
Expand Down
2 changes: 2 additions & 0 deletions src/arrays/aliasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This means that if the contents of the array are updated, that change will
be reflected by both variables.

```java
~void main() {
char[] lettersOne = { 'B', 'a', 't', 'm', 'a', 'n' };
char[] lettersTwo = lettersOne;

Expand All @@ -28,6 +29,7 @@ lettersTwo[0] = 'R';
System.out.println(lettersOne);
// Ratman
System.out.println(lettersTwo);
~}
```

When two variables point to the same thing like this we say that both variables are "aliases"
Expand Down
6 changes: 3 additions & 3 deletions src/arrays/array_initializers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ To give an initial value to an array you can use an array initializer.

After the equals sign you write `{` followed by a comma separated list of elements and a final `}`.

```java
int[] numbers = { 1, 2, 3 }
```java,no_run
int[] numbers = { 1, 2, 3 };
// |---------|
// this part is
// the initializer
```

The elements in an initializer do not have to be literals and can also be variables or expressions.

```java
```java,no_run
int two = 2;
// Will hold 1, 2, 3 just like the array above
int[] numbers = { 1, two, two + 1 }
Expand Down
8 changes: 4 additions & 4 deletions src/arrays/challenges.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Remember the rules for this are

Edit the following program so that the output is zero.

```java
```java,editable
void main() {
// Only change this line
String[] words = { "Sam", "I", "Am" };
Expand All @@ -22,7 +22,7 @@ void main() {
Using only `System.out.println` and array accesses,
print `hello world` to the screen.

```java
```java,editable
void main() {
char[] letters = {
' ',
Expand All @@ -44,7 +44,7 @@ void main() {
Without editing either the array declaration or the loop at the bottom,
make the output of this program `0`.

```java
```java,editable
void main() {
final int numbers = { 1, 2, 3, 4 };

Expand All @@ -68,7 +68,7 @@ void main() {
Make this program output `bulbasaur` without changing anything
above or below the marked areas.

```java
```java,editable
void main() {
char[] name = { 'b', 'u', 'l', 'b' };

Expand Down
2 changes: 1 addition & 1 deletion src/arrays/empty_array.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ System.out.println(emptyCharArray.length);

// Crash
System.out.println(emptyCharArray[0]);
```
```
4 changes: 3 additions & 1 deletion src/arrays/length.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
The number of elements which comprise an array can be accessed by using `.length`.[^unlike_string]

```java
~void main() {
String[] veggies = { "brussels", "cabbage", "carrots" };
int numberOfElements = veggies.length;

// veggies is 3 elements long
System.out.println(
"veggies is " numberOfElements + " characters long"
"veggies is " + numberOfElements + " characters long"
);
~}
```

[^unlike_string]: Unlike with a `String`, you do not write `()` after `.length`.
6 changes: 6 additions & 0 deletions src/arrays/printing_the_contents_of_an_array.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ you won't see the contents of the array. Instead you will see
something like `[Ljava.lang.String;@1c655221`.

```java
~void main() {
String[] shout = { "fus", "ro", "dah" };
// [Ljava.lang.String;@5a07e868
System.out.println(shout);
~}
```

A similar thing will happen with `int[]`, `boolean[]`, and `double[]`.[^gibberish]

```java
~void main() {
int[] nums = { 11, 11, 11 };
// [I@5a07e868
System.out.println(nums);
Expand All @@ -24,15 +27,18 @@ System.out.println(bools);
double[] doubles = { 1.1, 1.1, 1.1 };
// [D@5a07e868
System.out.println(bools);
~}
```

The only kind of array which will include its contents when printed is a `char[]`.
It will be printed as if it were a `String`.

```java
~void main() {
char[] continent = { 'T', 'a', 'm', 'r', 'i', 'e', 'l' };
// Tamriel
System.out.println(continent);
~}
```

If you want to actually see the contents of an array, you should
Expand Down
13 changes: 11 additions & 2 deletions src/arrays/reassignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,36 @@
The length of an array cannot change, but a variable holding an
array can be reassigned to a new array that has a different length.

When reassigning the value of an array variable you need to put `new` followed by a space, the type
of element held by the array, and then `[]` all before the initializer.

So to reassign an `int[]` you need to write something like `new int[] { 1, 2, 3 }`.

```java
~void main() {
int[] numbers = { 1, 2 };
// 2
System.out.println(numbers.length);

numbers = { numbers[0], numbers[1], 3 };
numbers = new int[] { numbers[0], numbers[1], 3 };
// 3
System.out.println(numbers.length);
~}
```

This reassignment will not be affect any variables which
are aliases for the variable's old value.

```java
~void main() {
char[] wordOne = { 'g', 'o' };
char[] wordTwo = wordOne;
// go
System.out.println(wordOne);
// go
System.out.println(wordTwo);

wordOne = { wordOne[0], wordOne[1], 's', 'h' };
wordOne = new int[] { wordOne[0], wordOne[1], 's', 'h' };

// gosh
System.out.println(wordOne);
Expand All @@ -44,4 +52,5 @@ wordOne[0] = 'p';
System.out.println(wordOne);
// no
System.out.println(wordTwo);
~}
```
2 changes: 2 additions & 0 deletions src/arrays/relation_to_final_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This means that the variable cannot be reassigned, but it does not mean
that the array's contents cannot be changed directly or through an alias.

```java
~void main() {
final char[] catchphrase = { 'w', 'o', 'a', 'h', '!' };
// woah!
System.out.println(catchphrase);
Expand All @@ -24,4 +25,5 @@ alias[4] = 's';

// egads
System.out.println(catchphrase);
~}
```
Loading