From 1ee3af84dd260629eb0f355a53a020550997369c Mon Sep 17 00:00:00 2001 From: "Mr Mystery 1.0" <69641472+MrMystery10-del@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:26:04 +0100 Subject: [PATCH] Fixed codebox formatting of src/boxed_primitives --- src/boxed_primitives/boolean.md | 16 ++++----- src/boxed_primitives/boxing_conversion.md | 14 ++++---- src/boxed_primitives/character.md | 15 ++++---- src/boxed_primitives/double.md | 15 ++++---- src/boxed_primitives/integer.md | 12 +++---- src/boxed_primitives/unboxing_conversion.md | 40 ++++++++++----------- 6 files changed, 57 insertions(+), 55 deletions(-) diff --git a/src/boxed_primitives/boolean.md b/src/boxed_primitives/boolean.md index 2de4fc6..a659c86 100644 --- a/src/boxed_primitives/boolean.md +++ b/src/boxed_primitives/boolean.md @@ -1,12 +1,12 @@ # Boolean - The type to use for a `boolean` that might be null is `Boolean`. -```java -~void main() { -Boolean b = null; -System.out.println(b); -b = true; -System.out.println(true); -~} \ No newline at end of file +```java, no_run +void main() { + Boolean b = null; + System.out.println(b); + b = true; + System.out.println(true); +} +``` \ No newline at end of file diff --git a/src/boxed_primitives/boxing_conversion.md b/src/boxed_primitives/boxing_conversion.md index 13e2449..1d6918e 100644 --- a/src/boxed_primitives/boxing_conversion.md +++ b/src/boxed_primitives/boxing_conversion.md @@ -4,14 +4,14 @@ If you try to assign to a boxed type like `Integer` from some code that gives you the unboxed version like `int`, then Java will automatically do that conversion.[^obvious] -```java -~void main() { -int x = 5; -Integer y = x; +```java, no_run +void main() { + int x = 5; + Integer y = x; -System.out.println(x); -System.out.println(y); -~} + System.out.println(x); + System.out.println(y); +} ``` [^obvious]: This might feel obvious, but this is one of the few places in Java where the type of something "magically" changes. `int` and `Integer`, `char` and `Character`, etc. *are* different types. \ No newline at end of file diff --git a/src/boxed_primitives/character.md b/src/boxed_primitives/character.md index 7ec17ce..b6b3b81 100644 --- a/src/boxed_primitives/character.md +++ b/src/boxed_primitives/character.md @@ -2,10 +2,11 @@ The type to use for a `char` that might be null is `Character`. -```java -~void main() { -Character c = null; -System.out.println(c); -c = '%'; -System.out.println(c); -~} \ No newline at end of file +```java, no_run +void main() { + Character c = null; + System.out.println(c); + c = '%'; + System.out.println(c); +} +``` \ No newline at end of file diff --git a/src/boxed_primitives/double.md b/src/boxed_primitives/double.md index 6655c41..50e2c64 100644 --- a/src/boxed_primitives/double.md +++ b/src/boxed_primitives/double.md @@ -2,10 +2,11 @@ The type to use for a `double` that might be null is `Double`. -```java -~void main() { -Double d = null; -System.out.println(d); -d = 3.14; -System.out.println(d); -~} \ No newline at end of file +```java, no_run +void main() { + Double d = null; + System.out.println(d); + d = 3.14; + System.out.println(d); +} +``` \ No newline at end of file diff --git a/src/boxed_primitives/integer.md b/src/boxed_primitives/integer.md index 95f8cf0..e5732d7 100644 --- a/src/boxed_primitives/integer.md +++ b/src/boxed_primitives/integer.md @@ -2,11 +2,11 @@ The type to use for an `int` that might be null is `Integer`. -```java -~void main() { -Integer i = null; -System.out.println(i); -i = 5; -System.out.println(i); +```java, no_run +void main() { + Integer i = null; + System.out.println(i); + i = 5; + System.out.println(i); ~} ``` \ No newline at end of file diff --git a/src/boxed_primitives/unboxing_conversion.md b/src/boxed_primitives/unboxing_conversion.md index c0005f9..8467414 100644 --- a/src/boxed_primitives/unboxing_conversion.md +++ b/src/boxed_primitives/unboxing_conversion.md @@ -5,25 +5,25 @@ the normal type is expected, it will be implicitly "unboxed." This means you can use `Integer`s directly in math expressions. -```java -~void main() { -Integer x = 5; -int y = 3; -int z = x * y; - -System.out.println(z); -~} +```java, no_run +void main() { + Integer x = 5; + int y = 3; + int z = x * y; + + System.out.println(z); +} ``` As well as `Boolean`s in logical expressions. -```java -~void main() { -Boolean hasHat = true; -if (hasHat) { - System.out.println("You have a hat!"); +```java, no_run +void main() { + Boolean hasHat = true; + if (hasHat) { + System.out.println("You have a hat!"); + } } -~} ``` And so on for `Double`, `Character`, etc. @@ -31,10 +31,10 @@ And so on for `Double`, `Character`, etc. But if you use one of these types like this and they happen to be `null` you will get a `NullPointerException`. -```java,panics -~void main() { -Integer x = null; -// Bool -int y = x; -~} +```java, panics +void main() { + Integer x = null; + // Bool + int y = x; +} ``` \ No newline at end of file