15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/components/Button.svelte:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 | {text}
12 | {#if arrow}
13 |
14 | {/if}
15 |
16 |
17 |
--------------------------------------------------------------------------------
/static/icons/right-arrow.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./.svelte-kit/tsconfig.json",
3 | "compilerOptions": {
4 | "allowJs": true,
5 | "checkJs": true,
6 | "esModuleInterop": true,
7 | "forceConsistentCasingInFileNames": true,
8 | "resolveJsonModule": true,
9 | "skipLibCheck": true,
10 | "sourceMap": true,
11 | "strict": true,
12 | "moduleResolution": "bundler"
13 | }
14 | // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
15 | // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
16 | //
17 | // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
18 | // from the referenced tsconfig.json - TypeScript does not merge them in
19 | }
20 |
--------------------------------------------------------------------------------
/svelte.config.js:
--------------------------------------------------------------------------------
1 | import adapter from '@sveltejs/adapter-auto';
2 | import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
3 |
4 | /** @type {import('@sveltejs/kit').Config} */
5 | const config = {
6 | // Consult https://svelte.dev/docs/kit/integrations
7 | // for more information about preprocessors
8 | preprocess: vitePreprocess(),
9 |
10 | kit: {
11 | // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
12 | // If your environment is not supported, or you settled on a specific environment, switch out the adapter.
13 | // See https://svelte.dev/docs/kit/adapters for more information about adapters.
14 | adapter: adapter()
15 | }
16 | };
17 |
18 | export default config;
19 |
--------------------------------------------------------------------------------
/static/questions/bases.json:
--------------------------------------------------------------------------------
1 | {
2 | "questions": [
3 | {
4 | "question": "Which of the following is NOT equivalent to `1100011₂ + 10011101₂`?",
5 | "answers": [
6 | "`256₁₀`",
7 | "`400₈`",
8 | "`100₁₆`",
9 | "`100000000₂`",
10 | "`All are`"
11 | ],
12 | "correct": 4,
13 | "explanation": "Convert each value to base 10 and add them together. 1100011₂ in base 10 is 99. 10011101₂ in base 10 is 157. 99 + 157 = 256₁₀. Converted to base 8 that is 400₈. Converted to base 16 that is 100₁₆. Converted to base 2 that is 100000000₂. Since all values are equivalent, the answer is `All are`.",
14 | "source": "UIL Test"
15 | }
16 | ]
17 | }
--------------------------------------------------------------------------------
/eslint.config.js:
--------------------------------------------------------------------------------
1 | import prettier from 'eslint-config-prettier';
2 | import js from '@eslint/js';
3 | import { includeIgnoreFile } from '@eslint/compat';
4 | import svelte from 'eslint-plugin-svelte';
5 | import globals from 'globals';
6 | import { fileURLToPath } from 'node:url';
7 | import ts from 'typescript-eslint';
8 | const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
9 |
10 | export default ts.config(
11 | includeIgnoreFile(gitignorePath),
12 | js.configs.recommended,
13 | ...ts.configs.recommended,
14 | ...svelte.configs['flat/recommended'],
15 | prettier,
16 | ...svelte.configs['flat/prettier'],
17 | {
18 | languageOptions: {
19 | globals: {
20 | ...globals.browser,
21 | ...globals.node
22 | }
23 | }
24 | },
25 | {
26 | files: ['**/*.svelte'],
27 |
28 | languageOptions: {
29 | parserOptions: {
30 | parser: ts.parser
31 | }
32 | }
33 | }
34 | );
35 |
--------------------------------------------------------------------------------
/src/lib/Analytics.svelte:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
30 |
--------------------------------------------------------------------------------
/static/questions/math.json:
--------------------------------------------------------------------------------
1 | {
2 | "questions": [
3 | {
4 | "question": "What is the output by the code below? \n ```java\nlong num1 = Math.floorDiv(7, 3);\ndouble num2 = Math.pow(2, 3);\nout.println(Math.min(num1, num2));\n```",
5 | "answers": [
6 | "`2`",
7 | "`2.0`",
8 | "`8`",
9 | "`8.0`",
10 | "There is no output due to a runtime error."
11 | ],
12 | "correct": 1,
13 | "explanation": "`7 / 3` is about `2.33333`, floored is `2`, which is stored into `num1`. `2` cubed is `8`, which is stored in `num2`. `2` < `8`, so `Math.min()` will return `2`, however, since one of the arguments is a `double` (`num2`), the function will return a `double`, so the answer is `2`.",
14 | "source": "UIL Computer Science Written Test - 2025 Invitational B"
15 | }
16 | ]
17 | }
--------------------------------------------------------------------------------
/static/social/github-mark-white.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/questions/precedence.json:
--------------------------------------------------------------------------------
1 | {
2 | "questions": [
3 | {
4 | "question": "What is the output by the code below? \n ```java\nout.println((-17 % 7) | (11 << 3));\n```",
5 | "answers": [
6 | "`91`",
7 | "`-3`",
8 | "`88`",
9 | "`-91`",
10 | "There is no output due to a compile error"
11 | ],
12 | "correct": 1,
13 | "explanation": "The code will first evaluate the expression `(-17 % 7)`. The remainder of `-17 / 7` is -3, so the result of this expression is `-3`. The code will then evaluate the expression `(11 << 3)`. `11` in binary is `1011`, and shifted `3` over turns it into `1011000`, which is `88`. The code will then evaluate the expression `-3 | 88`. The result of this expression is `-3`. The output will be `-3`.",
14 | "source": "UIL Computer Science Written Test - 2025 Invitational B"
15 | }
16 | ]
17 | }
--------------------------------------------------------------------------------
/src/components/Navbar.svelte:
--------------------------------------------------------------------------------
1 |
12 |
13 |
--------------------------------------------------------------------------------
/src/routes/reference/+page.svelte:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
Reference Sheet
7 |
This is the class reference sheet. You'll get one at every competition, and it contains useful info for what returns types and parameters are for certain functions, classes, and interfaces. You can also open it in a new tab.
This page contains a list of all current topics covered on the UIL test. Each one contains a cheatsheet, and may contain a guide over the topic or questions relating to the topic to improve your skills.
34 | {/if}
35 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # UIL CS Toolkit
2 |
3 | An all-in-one toolkit for everything you need for the University Interscholastic League Computer Science Competition, from cheatsheets and guides about important topics, to questions directly from UIL tests to help you improve.
4 |
5 | Visit the [website](https://uil-cs-toolkit.vercel.app) to get started!
6 |
7 | ## Features
8 |
9 | * Resources --- View Resources relating to Java topics. This can range from other websites to practice Java programming, to Java fundamentals, to focusing on certain subtopics like strings or bases. Practice programming with LeetCode or study Java fundamentals with W3Schools
10 | * Reference Sheet --- Check out reference material that is given to you on the day of the UIL competition.
11 | * Topics --- View different topics to help you get better, from strings, arrays, bases, Big O, etc. Quickly go over important topics using cheatsheets and view long form resources for learning more about topics.
12 |
13 | ## Topic List
14 |
15 | * Bases
16 | * BigO
17 | * Math
18 | * Primitives
19 | * Strings
20 |
21 | ## Run Locally
22 |
23 | If you'd like to run UIL CS Toolkit on your own computer, you'll need `NodeJS` installed on your computer.
24 |
25 | After you've done that, clone the repo wherever you'd like, then run these commands:
26 |
27 | ``` bash
28 | npm i
29 | npm run dev -- --open
30 | ```
31 |
32 | The website should automatically open in your default browser
33 |
--------------------------------------------------------------------------------
/src/components/SEO.svelte:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 | {title}
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | {@html ` `}
37 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "uil-cs-cheatsheet",
3 | "private": true,
4 | "version": "0.0.1",
5 | "type": "module",
6 | "scripts": {
7 | "dev": "vite dev",
8 | "build": "vite build",
9 | "preview": "vite preview",
10 | "prepare": "svelte-kit sync || echo ''",
11 | "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
12 | "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
13 | "format": "prettier --write .",
14 | "lint": "prettier --check . && eslint ."
15 | },
16 | "devDependencies": {
17 | "@eslint/compat": "^1.2.5",
18 | "@eslint/js": "^9.18.0",
19 | "@sveltejs/adapter-auto": "^4.0.0",
20 | "@sveltejs/kit": "^2.16.0",
21 | "@sveltejs/vite-plugin-svelte": "^5.0.0",
22 | "@tailwindcss/vite": "^4.0.0",
23 | "@types/gtag.js": "^0.0.20",
24 | "@types/markdown-it": "^14.1.2",
25 | "@types/node": "^22.13.4",
26 | "eslint": "^9.18.0",
27 | "eslint-config-prettier": "^10.0.1",
28 | "eslint-plugin-svelte": "^2.46.1",
29 | "globals": "^15.14.0",
30 | "prettier": "^3.4.2",
31 | "prettier-plugin-svelte": "^3.3.3",
32 | "prettier-plugin-tailwindcss": "^0.6.11",
33 | "svelte": "^5.0.0",
34 | "svelte-check": "^4.0.0",
35 | "tailwindcss": "^4.0.0",
36 | "typescript": "^5.0.0",
37 | "typescript-eslint": "^8.20.0",
38 | "vite": "^6.2.4"
39 | },
40 | "dependencies": {
41 | "@sindresorhus/slugify": "^2.2.1",
42 | "highlight.js": "^11.11.1",
43 | "markdown-it": "^14.1.0",
44 | "markdown-it-anchor": "^9.2.0",
45 | "markdown-it-collapsible": "^2.0.2",
46 | "markdown-it-highlightjs": "^4.2.0"
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/routes/resources/resources.md:
--------------------------------------------------------------------------------
1 | # UIL Programming Resources
2 |
3 | Use these resources to practice for upcoming UIL tests, along with learning more about Java through practice.
4 |
5 | ## Links
6 |
7 | ### Places to Practice/Compete
8 |
9 | - [CodingBat](https://codingbat.com/java)
10 | - Good for beginners
11 | - Good for learning Java basics, up to recursion
12 | - [Hackerrank](https://www.hackerrank.com/)
13 | - Good for indermediates
14 | - Has quite a lot of practice problems
15 | - [Leetcode](https://leetcode.com/)
16 | - Far more challenging questions than others listed
17 | - Helpful for the programming section of the competition
18 | - [USACO](https://usaco.org/)
19 | - Extremely Good for practicing programming
20 | - [Codeforces](https://codeforces.com/)
21 | - [AtCoder](https://atcoder.jp/)
22 | - [HackerEarth](https://hackerearth.com/)
23 | - [Kattis](https://open.kattis.com/)
24 | - [Virtual Judge](https://vjudge.net/)
25 | - [CS Academy](https://csacademy.com/)
26 | - [CodeChef](https://codechef.com/)
27 | - [Topcoder](https://topcoder.com/)
28 | - [Timus Online Judge](https://acm.timus.ru/)
29 | - [TLX](https://tlx.toki.id/)
30 | - [SPOJ](https://spoj.com/)
31 | - [DMOJ](https://dmoj.ca/)
32 |
33 | ### Documention
34 |
35 | - [Java Documentation](https://docs.oracle.com/en/java/javase/18/docs/api/)
36 | - Full list of all functions that are used inside Java
37 |
38 | ### Tutorials
39 |
40 | - [W3 Schools Java Tutorial](https://www.w3schools.com/java/)
41 | - Full tutorial and guide for all Java basics
42 | - [Regular Expressions](https://rexegg.com/)
43 | - A comprehensive list of all regular expresion tricks
44 | - [USACO Guide](https://usaco.guide/)
45 | - [CSES Problem Set](https://cses.fi/problemset/)
46 | - [USACO Training Gateway](https://train.usaco.org/)
47 | - [TopCoder CP Tutorials](https://topcoder.com/community/competitive-programming/tutorials)
48 | - [CS 97SI Stanford Course](https://web.stanford.edu/class/cs97si/)
49 |
50 | ### Testing
51 |
52 | - [Regular Expressions](https://regex101.com/)
53 | - A place to test regular expressions against test strings
54 |
55 | ### Resources
56 |
57 | - [CP Algorithms](https://cp-algorithms.com/)
58 | - Contains a list of most algorithms used for competitive programming.
59 | - [Geeks for Geeks](https://geeksforgeeks.org/fundamentals-of-algorithms)
60 |
61 | ### Calendars
62 |
63 | - [CP Calendar](https://competitiveprogramming.info/calendar/)
64 | - An upcoming list of most competitive programming challenges
65 | - [Hackerrank Calendar](https://hackerrank.com/calendar)
66 |
--------------------------------------------------------------------------------
/static/questions/strings.json:
--------------------------------------------------------------------------------
1 | {
2 | "questions": [
3 | {
4 | "question": "``` java\nString t = \"MississippiBurning\";\nt.replaceAll(\"i\",\"U\");\nout.println(t);\n```\n\nWhat is output by the code segment above?",
5 | "answers": [
6 | "`MississippiBurning`",
7 | "`MUssUssUppUBurnUng`",
8 | "`MussussuppuBurnung`",
9 | "`MississippiBirning`",
10 | "There is no output due to an error."
11 | ],
12 | "correct": 0,
13 | "explanation": "The `replaceAll` method returns a new string with the replacement made. The original string is not modified. The code should be `t = t.replaceAll(\"i\",\"U\");`. Remember that strings are immutable.",
14 | "source": "UIL Test"
15 | }, {
16 | "question": "``` java\nString s = \"pneumonoultramicroscop\"+\n \"icsilicovolcanoconiosis\";\nwhile (s.length() > 10) {\n s = s.substring(3);\n}\nout.println(s);\n```\n\nWhat is output by the code segment above?",
17 | "answers": [
18 | "`oconiosis`",
19 | "`noconiosis`",
20 | "`pneumonou`",
21 | "`pneumonoul`",
22 | "There is no output due to an error."
23 | ],
24 | "correct": 1,
25 | "explanation": "The code will remove the first 3 characters of the string until the length of the string is less than or equal to 10. The output will be `noconiosis`.",
26 | "source": "UIL Test"
27 | }, {
28 | "question": "Assuming that indented lines are continuations of the previous line, what is the output by the code to the right?\n```java\nString s1 =\n\t\"hEllo thEre... GEnEral KEnobi\";\nString s2 = s1.toLowerCase();\nString[] arr1 = s1.split(\"E\");\nString[] arr2 = s2.split(\"E\");\nint diff = arr1.length -\n\tarr2.length;\nout.println(diff);",
29 | "answers": [
30 | "`-6`",
31 | "`-5`",
32 | "`5`",
33 | "`6`",
34 | "There is no output due to an error."
35 | ],
36 | "correct": 2,
37 | "explanation": "First off, since `s2` has no `E`'s, as it was converted to lowercase, `split` will return an array with size `1`. When `s1` is split by `E`'s, it splits the string into this array: `[\"h\", \"llo th\", \"re... G\", \"n\", \"ral K\", \"nobi\"]`, which has a length of `6`. `6 - 1 = 5`, so our answer is `5`.",
38 | "source": "UIL Computer Science Written Test - 2025 Invitational B"
39 | }
40 | ]
41 | }
--------------------------------------------------------------------------------
/src/routes/+page.svelte:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
UIL Computer Science Toolkit
10 |
An all-in-one toolkit for everything you need for the University Interscholastic League Computer Science Competition, from cheatsheets and guides about important topics, to questions directly from UIL tests to help you improve.
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
Resources
20 |
View Resources relating to Java topics. This can range from other websites to practice Java programming, to Java fundamentals, to focusing on certain subtopics like strings or bases. Practice programming with LeetCode or study Java fundamentals with W3Schools
21 |
22 |
23 |
24 |
Reference Sheet
25 |
Check out reference material that is given to you on the day of the UIL competition.
26 |
27 |
28 |
29 |
Topics
30 |
View different topics to help you get better, from strings, arrays, bases, Big O, etc. Quickly go over important topics using cheatsheets and view long form resources for learning more about topics.
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/static/cheatsheet/bases.md:
--------------------------------------------------------------------------------
1 | # Number Bases Cheatsheet
2 |
3 | - [Number Bases Cheatsheet](#number-bases-cheatsheet)
4 | - [Common Bases](#common-bases)
5 | - [Letter Representations](#letter-representations)
6 | - [Converting Between Bases](#converting-between-bases)
7 | - [Java Functions](#java-functions)
8 | - [Base Prefixes](#base-prefixes)
9 | - [Twos compilment (Signed values)](#twos-compilment-signed-values)
10 |
11 | ## Common Bases
12 |
13 | | Base # | | | | | | | | |
14 | | ------- | --- | --- | ------ | ----- | ---- | --- | --- | --- |
15 | | Base 2 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
16 | | Base 8 | | | 32768 | 4096 | 512 | 64 | 8 | 1 |
17 | | Base 10 | | | 100000 | 10000 | 1000 | 100 | 10 | 1 |
18 | | Base 16 | | | | | 4096 | 256 | 16 | 1 |
19 |
20 | ## Letter Representations
21 |
22 | | `A` | `B` | `C` | `D` | `E` | `F` |
23 | | --- | --- | --- | --- | --- | --- |
24 | | 10 | 11 | 12 | 13 | 14 | 15 |
25 |
26 | ## Converting Between Bases
27 |
28 | - Can only only convert between bases that is a power of that base
29 | - Split into block sizes, where `x` is the original base, and `y` is the base to convert to:
30 | - Converting to higher base: `logₓ(y)`
31 | - Converting to lower base: `ʸ√x`
32 | - Blocks form from right to left.
33 | - When converting to a higher base:
34 | - Take each block to base `10`, then put them together.
35 | - When converting to a lower base:
36 | - Take each block and make it into the base you are converting to.
37 | - If necessary, pad each block to the size it must be
38 |
39 | ## Java Functions
40 |
41 | | Function Name | Parameters | Return |
42 | | -------------------------- | ----------------------------------------------------------------- | ------------------------------------------------ |
43 | | `Integer.toString()` | `int num`: Number in base 10 `int radix`: Base to convert to | `String`: Converted Number as a string |
44 | | `Integer.toBinaryString()` | `int num`: Number in base 10 | `String`: Converted Number in Base 2 as a string |
45 |
46 | ## Base Prefixes
47 |
48 | | Base | Prefix |
49 | | ---- | ------ |
50 | | `2` | `0b` |
51 | | `8` | `0` |
52 | | `16` | `0x` |
53 |
54 | ## Twos compilment (Signed values)
55 |
56 | - By default all values in Java are unsigned
57 | - With signed values, make the leftmost value negative:
58 |
59 | | Base # | | | | | | | | |
60 | | ------ | ---- | --- | --- | --- | --- | --- | --- | --- |
61 | | Base 2 | -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
62 |
--------------------------------------------------------------------------------
/static/cheatsheet/precedence.md:
--------------------------------------------------------------------------------
1 | # Operator Precedence
2 |
3 | - [Operator Precedence](#operator-precedence)
4 | - [Precedence Acronym \& Table](#precedence-acronym--table)
5 | - [Increment and Decrement](#increment-and-decrement)
6 | - [Unary Logical NOT](#unary-logical-not)
7 | - [Unary Bitwise NOT](#unary-bitwise-not)
8 | - [Casting](#casting)
9 | - [Shift](#shift)
10 | - [`instanceof`](#instanceof)
11 | - [Ternary](#ternary)
12 | - [Assignment](#assignment)
13 | - [Lambda](#lambda)
14 | - [Switch](#switch)
15 |
16 | ## Precedence Acronym & Table
17 |
18 | Remember the acronym **POUCMA SHREAXOR LOTAL**:
19 |
20 | > Associativity means which part of the operation comes first.
21 | > For example, subtraction is left-to-right, meaning the left number is subtracted from the right.
22 | > Assignments are right-to-left, meaning the left value is set to the right expression.
23 |
24 | | Level | Name | Operator(s) | Description | Associativity |
25 | | ----- | ---- | ----------- | ----------- | ------------- |
26 | | 15 | Parenthesis | `()` `[]` `new` `.` `::` | parenthesis array access object creation member access method reference | left-to-right |
27 | | 14 | Other Unary | `++` `--` `!` `~` `++` `--` | unary post-increment unary post-decrement unary logical NOT unary bitwise NOT unary post-increment unary post-decrement | left-to-right (first two) right-to-left (last four) |
28 | | 13 | Casting | `(type)` | cast | right-to-left |
29 | | 12 | Multiplication | `*` `/` `%` | multiplication division modulo (remainder) | left-to-right |
30 | | 11 | Addition | `+` `-` | addition subtraction | left-to-right |
31 | | 10 | Shift | `>>` `<<` `>>>` | shift | left-to-right |
32 | | 9 | Relations | `< <=` `> >=` `instanceof` | relational | left-to-right |
33 | | 8 | Equality | `==` `!=` | equality | left-to-right |
34 | | 7 | Bitwise AND | `&` | bitwise AND | left-to-right |
35 | | 6 | Bitwise XOR | `^` | bitwise XOR | left-to-right |
36 | | 5 | Bitwise OR | `\|` | bitwise OR | left-to-right |
37 | | 4 | Logical AND | `&&` | logical AND | left-to-right |
38 | | 3 | Logical OR | `\|\|` | logical OR | left-to-right |
39 | | 2 | Ternary | `?:` | ternary | left-to-right |
40 | | 1 | Assignment | `= += -=` `*= /= %=` `&= ^= \|=` `<<= >>= >>>=` | assignment | right-to-left |
41 | | 0 | Lambda | `->` | lambda/switch expression | right-to-left |
42 |
43 | ## Increment and Decrement
44 |
45 | ## Unary Logical NOT
46 |
47 | ## Unary Bitwise NOT
48 |
49 | ## Casting
50 |
51 | ## Shift
52 |
53 | ## `instanceof`
54 |
55 | ## Ternary
56 |
57 | ## Assignment
58 |
59 | ## Lambda
60 |
61 | ## Switch
62 |
--------------------------------------------------------------------------------
/static/cheatsheet/primitives.md:
--------------------------------------------------------------------------------
1 | # Primitives Cheatsheet
2 |
3 | - [Primitives Cheatsheet](#primitives-cheatsheet)
4 | - [Primitive Types](#primitive-types)
5 | - [Integer Division](#integer-division)
6 | - [Modulus](#modulus)
7 | - [Number Suffixes](#number-suffixes)
8 | - [Default Values](#default-values)
9 | - [Links](#links)
10 |
11 | ## Primitive Types
12 |
13 | | Name | Bits | Signed | Range |
14 | | --------- | ---- | ------ | -------------------------------------------------------- |
15 | | `boolean` | `8` | `No` | `false` or `true` |
16 | | `byte` | `8` | `Yes` | `-128` to `127` |
17 | | `char` | `16` | `No` | `0` to `65535` |
18 | | `short` | `16` | `Yes` | `-32768` to `32767` |
19 | | `int` | `32` | `Yes` | `-2147483648` to `2147483647` |
20 | | `long` | `64` | `Yes` | `-9223372036854775808` to `9223372036854775807` |
21 | | `float` | `32` | | `1.40239846e-45` to `3.40282347e+38` |
22 | | `double` | `64` | | `4.94065645841246544e-324` to `1.79769313486231570e+308` |
23 |
24 | ## Integer Division
25 |
26 | - Division between two `number` values (`byte`, `short`, `int`, `long`) will truncate the decimal.
27 | - Division between a decimal value (`float`, `double`) and a `number` value will produce a decimal.
28 |
29 | ``` java
30 | 2 / 3 = 0
31 | 16 / 5 = 3
32 | 8 / 4 = 2
33 | -10 / 7 = -1
34 | 2.0 / 3 = 0.6666
35 | 16 / 5. = 3.2
36 | (double) 1 / 6 = 0.1666
37 | 9d / 4 = 2.25
38 | ```
39 |
40 | ## Modulus
41 |
42 | - `%` symbol takes the remainder
43 |
44 | ``` java
45 | 16 % 2 == 0;
46 | x % 2 == 0; // Is x even?
47 | x % 3 != 0; // Is x NOT a multiple of 3
48 | ```
49 |
50 | ## Number Suffixes
51 |
52 | Certain Data types have suffixes that specify what type they are.
53 | **Not using these may cause errors**
54 |
55 | ``` java
56 | long l = 12345L;
57 | float f = 100.123f;
58 | double d = 9876.12345d;
59 | ```
60 |
61 | ## Default Values
62 |
63 | If no value is specified, the types will default to:
64 |
65 | | Data Type | Default Value |
66 | | ---------------------- | ------------- |
67 | | `byte`, `short`, `int` | `0` |
68 | | `float` | `0f` |
69 | | `double` | `0d` |
70 | | `long` | `0L` |
71 | | `char` | `'\u0000'` |
72 | | `Object` | `null` |
73 | | `boolean` | `false` |
74 |
75 | ## Links
76 |
77 | - [Official Primitives Guide](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html)
78 | - [W3 Schools Data Types Guide](https://www.w3schools.com/java/java_data_types.asp)
79 |
--------------------------------------------------------------------------------
/src/routes/topics/[slug]/[part]/+page.svelte:
--------------------------------------------------------------------------------
1 |
33 |
34 | {#snippet partSelection(part: string)}
35 |
38 | {part}
39 |
40 | {/snippet}
41 |
42 | {#if !topic}
43 |
76 | {/if}
77 |
78 |
--------------------------------------------------------------------------------
/static/cheatsheet/bigo.md:
--------------------------------------------------------------------------------
1 | # BigO Notation Cheatsheet
2 |
3 | - [BigO Notation Cheatsheet](#bigo-notation-cheatsheet)
4 | - [Time Complexities (in order from fastest to slowest)](#time-complexities-in-order-from-fastest-to-slowest)
5 | - [`O(1)` - Constant Time](#o1---constant-time)
6 | - [`O(log(n))` - Logarithmic Time](#ologn---logarithmic-time)
7 | - [`O(n)` - Linear Time](#on---linear-time)
8 | - [`O(n*log(n))` - Loglinear Time](#onlogn---loglinear-time)
9 | - [`O(n^2)` - Quadratic Time](#on2---quadratic-time)
10 | - [`O(2^n)` - Exponential Time](#o2n---exponential-time)
11 | - [`O(n!)` - Factorial Time](#on---factorial-time)
12 | - [Links](#links)
13 |
14 | BigO Notation is a way to determine how fast a program can run, like sorts and searches.
15 | `n` is the number of items in the dataset.
16 |
17 | Each nested for loop adds a power to the complexity. For example, it goes from `n` to `n^2` to `n^3` to `n^4` etc.
18 |
19 | Complexities next to each other are added. For example, a `O(n)` algorithm next to a `O(n^2)` algorithm, the final notation is `O(n + n^2)`.
20 |
21 | > Two `O(1)` algorithms added together are still `O(1)`
22 |
23 | ## Time Complexities (in order from fastest to slowest)
24 |
25 | 
26 |
27 | ### `O(1)` - Constant Time
28 |
29 | This is instant time. This includes things like:
30 |
31 | - Math Equations `(10 + 2)`
32 | - Printing
33 | - Accessing elements of an `Array` / `Arraylist`
34 | - Accessing elements of a `HashMap` / `HashSet`
35 |
36 | ### `O(log(n))` - Logarithmic Time
37 |
38 | This is essentially running a `for i loop` from `0 to n` and another `for loop` running from `i to n`. Includes things such as:
39 |
40 | - Worst Space Complexity of `Quicksort`
41 |
42 | Example:
43 |
44 | ``` java
45 | for (int i = 0; i < n; i++)
46 | for (int j = i; j < n; j++)
47 | System.out.println(i + j);
48 | ```
49 |
50 | ### `O(n)` - Linear Time
51 |
52 | A basic `for loop`, where `n` is the number of elements. This includes:
53 |
54 | - Looping over an `Array` / `Arraylist`
55 | - Basic Loop search
56 |
57 | Example:
58 |
59 | ``` java
60 | for (int i = 0; i < n; i++)
61 | System.out.println(i);
62 | ```
63 |
64 | ### `O(n*log(n))` - Loglinear Time
65 |
66 | Loglinear time. Includes:
67 |
68 | - Best / Average case `Quicksort`
69 | - Best / Average / Worse case `Mergesort`
70 | - Best / Average / Worse case `Heapsort`
71 |
72 | ### `O(n^2)` - Quadratic Time
73 |
74 | Two `for loops`, each looping from `0 to n`. Includes:
75 |
76 | - Worst case `Quicksort`
77 | - Average / Worst case `Bubble Sort`
78 | - Average / Worst case `Insertion Sort`
79 | - Best / Average / Worst case `Selection Sort`
80 |
81 | Example:
82 |
83 | ``` java
84 | for (int i = 0; i < n; i++)
85 | for (int j = 0; j < n; j++)
86 | System.out.println(i + j);
87 | ```
88 |
89 | ### `O(2^n)` - Exponential Time
90 |
91 | Includes things like:
92 |
93 | - Getting Combinations
94 |
95 | ### `O(n!)` - Factorial Time
96 |
97 | Worst time complexity. Includes things like:
98 |
99 | - Traveling Salesman Problem
100 |
101 | ## Links
102 |
103 | - [BigO Examples](https://javachallengers.com/big-o-notation-explanation/)
104 |
--------------------------------------------------------------------------------
/static/cheatsheet/math.md:
--------------------------------------------------------------------------------
1 | # Math Cheatsheet
2 |
3 | - [Math Cheatsheet](#math-cheatsheet)
4 | - [Constants](#constants)
5 | - [Functions](#functions)
6 | - [Function Examples](#function-examples)
7 | - [Random in range](#random-in-range)
8 | - [Links](#links)
9 |
10 | The `Math` class does **not** need to be imported
11 |
12 | ## Constants
13 |
14 | All constants are `doubles`
15 |
16 | | Constant | Value |
17 | | --------- | ----- |
18 | | `Math.PI` | `π` |
19 | | `Math.E` | `E` |
20 |
21 | ## Functions
22 |
23 | > Functions with a type of `number` accept types `double`, `float`, `int`, `long`
24 | > Functions with a type of `integer` accept types `int`, `long`
25 | > The return type will match the parameter type
26 |
27 | | Function Name | Parameters | Return |
28 | | ------------------ | ------------------------- | --------------------------------------------------- |
29 | | `Math.abs() *` | `number a` | `number`: Absolute Value |
30 | | `Math.pow()` | `double a`, `double b` | `double`: `a` to the power of `b` |
31 | | `Math.sqrt()` | `double a` | `double`: The square root of `a` |
32 | | `Math.cbrt()` | `double a` | `double`: The cube root of `a` |
33 | | `Math.min()` | `number a`, `number b` | `number`: Smallest number between `a` and `b` |
34 | | `Math.max()` | `number a`, `number b` | `number`: Largest number between `a` and `b` |
35 | | `Math.sin()` | `double a` **in radians** | `double`: trigonometric sine of an angle |
36 | | `Math.cos()` | `double a` **in radians** | `double`: trigonometric cosine of an angle |
37 | | `Math.tan()` | `double a` **in radians** | `double`: trigonometric tangent of an angle |
38 | | `Math.toRadians()` | `double a` **in degrees** | `double`: Converts degrees to radians |
39 | | `Math.hypot()` | `double a`, `double b` | `double`: Hypotenuse of a triangle (`sqrt(x2 +y2)`) |
40 | | `Math.floor()` | `double a` | `double`: Truncates `a` |
41 | | `Math.ceil()` | `double a` | `double`: Rounds `a` up to the nearest whole number |
42 | | `Math.round()` | `double a` | `long`: `a` rounded to the nearest whole number |
43 | | `Math.round()` | `float a` | `int`: `a` rounded to the nearest whole number |
44 | | `Math.random()` | | `double`: Random number in the range `0 <= x < 1` |
45 | | `Math.floorDiv()` | `integer a`, `integer b` | `int`: Performs Division, then floors the value |
46 |
47 | ## Function Examples
48 |
49 | ``` java
50 | Math.abs(-3) = 3;
51 | Math.pow(7, 2) = 49.0;
52 | Math.sqrt(64) = 8.0;
53 | Math.cbrt(64) = 4.0;
54 | Math.min(2, 4) = 2;
55 | Math.max(2, 4) = 4;
56 | Math.sin(0) = 0.0;
57 | Math.cos(Math.PI) = -1.0;
58 | Math.tan(0) = 0.0;
59 | Math.toRadians(90) = 1.5707;
60 | Math.hypot(3, -4) = 5.0;
61 | Math.floor(4.8) = 4.0;
62 | Math.ceil(4.8) = 5.0;
63 | Math.round(4.5) = 5;
64 | ```
65 |
66 | ## Random in range
67 |
68 | ``` java
69 | // Returns a number between min (inclusive) and max (inclusive)
70 | public static randInRange(int min, int max) {
71 | return (int)(Math.random() * ((max - min) + 1)) + min;
72 | }
73 | ```
74 |
75 | ## Links
76 |
77 | - [Math Class Documentation](https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html)
78 |
--------------------------------------------------------------------------------
/static/guide/bases.md:
--------------------------------------------------------------------------------
1 | # Number Bases
2 |
3 | ## Table of Contents
4 |
5 | - [Number Bases](#number-bases)
6 | - [Table of Contents](#table-of-contents)
7 | - [What is a base?](#what-is-a-base)
8 | - [Reading Base Numbers](#reading-base-numbers)
9 | - [Bases bigger than 10](#bases-bigger-than-10)
10 | - [Converting Between Bases](#converting-between-bases)
11 | - [Converting Backwards](#converting-backwards)
12 | - [Using Bases in Java](#using-bases-in-java)
13 |
14 | ## What is a base?
15 |
16 | Number bases are different ways we can represent numbers.
17 | In our everyday life, we use base `10` to represent numbers, like in our math classes or in conversation.
18 | A base can be written using a subscript after the number, for example `1110101₂` or `10,968₁₀`.
19 | Computers use base `2`, otherwise known as binary for representing their data.
20 | Other important bases to know are bases `8`, `10`, and `16`.
21 |
22 | ## Reading Base Numbers
23 |
24 | In order to read a number (e.x. `11101011₂`), we need to assign a number to each place, such as how we have the ones and tens place for base `10`:
25 |
26 | | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 1 |
27 | | --- | --- | --- | --- | --- | --- | --- | --- |
28 | | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
29 |
30 | The pattern for reading the bases is to start from one on the rightmost side, then keep multiplying it by the base number (in this case `2`, till you get to the leftmost value).
31 |
32 | In this scenario, if there is a `1` in a space, we add that number to the total.
33 | Since there is a `1` in the space of `128`, `64`, `32`, `8`, `2`, and `1`, we add all these up to get:
34 |
35 | `128 + 64 + 32 + 8 + 2 + 1 = 235`
36 |
37 | Therefore, `11101011₂` in base `10` is `235`.
38 |
39 | For other bases, such as base 8, we can do the same thing (e.x. `0631₈`):
40 |
41 | | 0 | 6 | 3 | 1 |
42 | | --- | --- | --- | --- |
43 | | 512 | 64 | 8 | 1 |
44 |
45 | Again, we start at one for the rightmost digit, then multiply by the base (`8`) going leftward.
46 |
47 | Since we have numbers bigger than one, we can multiply the number by the digit, so there are `6 64`'s, `3 8`'s, and `1 1`.
48 | We can add all these up to get:
49 |
50 | `64(6) + 8(3) + 1 = 409`.
51 |
52 | Therefore, `0631₈` in base `10` is `409`.
53 |
54 | ### Bases bigger than 10
55 |
56 | If there is a base bigger than 10, such as base `16`, we cannot say that there are `15` of a digit, because that number has two digits.
57 | Instead, we use letters to represent them:
58 |
59 | `A: 10, B: 11, C: 12, D: 13, E: 14, F: 15`.
60 |
61 | So, if there we have `15` in base `10`, then that would be `F` in base `16`
62 |
63 | ## Converting Between Bases
64 |
65 | Normally on the UIL test, the very first question will always be a base question.
66 | Usually they would have you do math, and the numbers are in different bases.
67 | One way to do this is to convert each number to base `10`, then do the math, then convert back into the bases of the answers, and see which one is right, but with certain bases, we can quickly convert between them.
68 |
69 | For example, base `2`. We can convert that easily to any base that is a power of `2`, such as `4`, `8`, or `16`.
70 |
71 | Lets try and convert `11101011₂` to base `16`. In order to that, you must first create `blocks`, and to get the block size, we can use `log₂(16)`, where the subscript is the base we are working with, and the number in parenthesis is the base we need to convert to.
72 |
73 | `log₂(16) = 4`, so we will be working with blocks of size `4`.
74 |
75 | Split the number into blocks of size `4`, starting from the left. With `11101011₂` we get two blocks: `1110` and `1011`.
76 |
77 | Convert each of those into base `10`, then combine them, and you have your number in base `16`:
78 |
79 | `1110` in base `10` is `14` or `E` (remember that `14` has two digits, so we have to convert it into a letter)
80 | `1011` in base `10` is `11` or `B`.
81 |
82 | So, `11101011₂` in base `16` is `EB`.
83 |
84 | ### Converting Backwards
85 |
86 | If we wish to convert `EB` back into base `2`, we can do that by once again using a block method.
87 | The formula this time will be `²√16`, were the superscript is the base we are going to, and the number within the square root symbol is our current base.
88 | Again, we need blocks of size `²√16 = 4`, so we take each character of `EB` (`E` and `B`), and convert them into base `2`, then make sure they have a block size of `4`.
89 |
90 | `E` in base `2` is `1110`, and `B` in base `2` is `1011`, so we have our original number of `11101011`.
91 |
92 | Make sure that if the number you get is of length `4`.
93 | If not, you can pad the left with `0's`.
94 |
95 | ### Converting Using Java
96 |
97 | Java has a few methods to help you convert between bases, most notably `Integer.toString`:
98 |
99 | ``` java
100 | Integer.toString(100, 2);
101 | ```
102 |
103 | This will convert the number `100` to base `2`, and return a string.
104 |
105 | You can also use `Integer.toBinaryString`, which takes in your base `10` number and outputs the binary
106 |
107 | ## Using Bases in Java
108 |
109 | In Java, basic numbers are read in as base `10`, but you can also use prefixes for numbers to represent them as certain bases:
110 |
111 | | Base | Prefix | Example |
112 | | ---- | ------ | -------------------- |
113 | | `2` | `0b` | `int i = 0b010 // 2` |
114 | | `8` | `0` | `int i = 010 // 8` |
115 | | `16` | `0x` | `int i = 0xA // 10` |
116 |
117 | ## Negative Numbers
118 |
119 | In order to use negative numbers, we use somethings called `twos compilment` and make the values `signed`.
120 | We take the leftmost value and make it negative, so the range changes from `0 to 256` to `-128 to 127`.
121 | By default, all primitives are `signed` in Java
122 |
--------------------------------------------------------------------------------
/static/cheatsheet/ascii.md:
--------------------------------------------------------------------------------
1 | # ASCII Table
2 |
3 | - [ASCII Table](#ascii-table)
4 | - [Important ASCII Values to Memorize](#important-ascii-values-to-memorize)
5 | - [Full ASCII Table](#full-ascii-table)
6 |
7 | You can find an ASCII table [here](https://www.asciitable.com) or down below
8 |
9 | ## Important ASCII Values to Memorize
10 |
11 | ``` txt
12 | 32 --- Space
13 | 48 --- 0
14 | 65 --- A
15 | 97 --- a
16 | ```
17 |
18 | It is VERY important that you memorize each of these.
19 | If you know these values, you can find any number/letter by calculating the offset from these four values.
20 |
21 | ## Full ASCII Table
22 |
23 | | Dec | Hx | Oct | Char |
24 | | --- | --- | --- | ------------------------------- |
25 | | 0 | 00 | 000 | NUL (null) |
26 | | 1 | 01 | 001 | SOH (start of heading) |
27 | | 2 | 02 | 002 | STX (start of text) |
28 | | 3 | 03 | 003 | ETX (end of text) |
29 | | 4 | 04 | 004 | EOT (end of transmission) |
30 | | 5 | 05 | 005 | ENQ (enquiry) |
31 | | 6 | 06 | 006 | ACK (acknowledge) |
32 | | 7 | 07 | 007 | BEL (bell) |
33 | | 8 | 08 | 010 | BS (backspace) |
34 | | 9 | 09 | 011 | TAB (horizontal tab) |
35 | | 10 | 0A | 012 | LF (line feed) |
36 | | 11 | 0B | 013 | VT (vertical tab) |
37 | | 12 | 0C | 014 | FF (form feed) |
38 | | 13 | 0D | 015 | CR (carriage return) |
39 | | 14 | 0E | 016 | SO (shift out) |
40 | | 15 | 0F | 017 | SI (shift in) |
41 | | 16 | 10 | 020 | DLE (data link escape) |
42 | | 17 | 11 | 021 | DC1 (device control 1) |
43 | | 18 | 12 | 022 | DC2 (device control 2) |
44 | | 19 | 13 | 023 | DC3 (device control 3) |
45 | | 20 | 14 | 024 | DC4 (device control 4) |
46 | | 21 | 15 | 025 | NAK (negative acknowledge) |
47 | | 22 | 16 | 026 | SYN (synchronous idle) |
48 | | 23 | 17 | 027 | ETB (end of transmission block) |
49 | | 24 | 18 | 030 | CAN (cancel) |
50 | | 25 | 19 | 031 | EM (end of medium) |
51 | | 26 | 1A | 032 | SUB (substitute) |
52 | | 27 | 1B | 033 | ESC (escape) |
53 | | 28 | 1C | 034 | FS (file separator) |
54 | | 29 | 1D | 035 | GS (group separator) |
55 | | 30 | 1E | 036 | RS (record separator) |
56 | | 31 | 1F | 037 | US (unit separator) |
57 | | 32 | 20 | 040 | Space |
58 | | 33 | 21 | 041 | ! |
59 | | 34 | 22 | 042 | " |
60 | | 35 | 23 | 043 | # |
61 | | 36 | 24 | 044 | $ |
62 | | 37 | 25 | 045 | % |
63 | | 38 | 26 | 046 | & |
64 | | 39 | 27 | 047 | ' |
65 | | 40 | 28 | 050 | ( |
66 | | 41 | 29 | 051 | ) |
67 | | 42 | 2A | 052 | \* |
68 | | 43 | 2B | 053 | + |
69 | | 44 | 2C | 054 | , |
70 | | 45 | 2D | 055 | - |
71 | | 46 | 2E | 056 | . |
72 | | 47 | 2F | 057 | / |
73 | | 48 | 30 | 060 | 0 |
74 | | 49 | 31 | 061 | 1 |
75 | | 50 | 32 | 062 | 2 |
76 | | 51 | 33 | 063 | 3 |
77 | | 52 | 34 | 064 | 4 |
78 | | 53 | 35 | 065 | 5 |
79 | | 54 | 36 | 066 | 6 |
80 | | 55 | 37 | 067 | 7 |
81 | | 56 | 38 | 070 | 8 |
82 | | 57 | 39 | 071 | 9 |
83 | | 58 | 3A | 072 | : |
84 | | 59 | 3B | 073 | ; |
85 | | 60 | 3C | 074 | < |
86 | | 61 | 3D | 075 | = |
87 | | 62 | 3E | 076 | > |
88 | | 63 | 3F | 077 | ? |
89 | | 64 | 40 | 100 | @ |
90 | | 65 | 41 | 101 | A |
91 | | 66 | 42 | 102 | B |
92 | | 67 | 43 | 103 | C |
93 | | 68 | 44 | 104 | D |
94 | | 69 | 45 | 105 | E |
95 | | 70 | 46 | 106 | F |
96 | | 71 | 47 | 107 | G |
97 | | 72 | 48 | 110 | H |
98 | | 73 | 49 | 111 | I |
99 | | 74 | 4A | 112 | J |
100 | | 75 | 4B | 113 | K |
101 | | 76 | 4C | 114 | L |
102 | | 77 | 4D | 115 | M |
103 | | 78 | 4E | 116 | N |
104 | | 79 | 4F | 117 | O |
105 | | 80 | 50 | 120 | P |
106 | | 81 | 51 | 121 | Q |
107 | | 82 | 52 | 122 | R |
108 | | 83 | 53 | 123 | S |
109 | | 84 | 54 | 124 | T |
110 | | 85 | 55 | 125 | U |
111 | | 86 | 56 | 126 | V |
112 | | 87 | 57 | 127 | W |
113 | | 88 | 58 | 130 | X |
114 | | 89 | 59 | 131 | Y |
115 | | 90 | 5A | 132 | Z |
116 | | 91 | 5B | 133 | [ |
117 | | 92 | 5C | 134 | \ |
118 | | 93 | 5D | 135 | ] |
119 | | 94 | 5E | 136 | ^ |
120 | | 95 | 5F | 137 | \_ |
121 | | 96 | 60 | 140 | ` |
122 | | 97 | 61 | 141 | a |
123 | | 98 | 62 | 142 | b |
124 | | 99 | 63 | 143 | c |
125 | | 100 | 64 | 144 | d |
126 | | 101 | 65 | 145 | e |
127 | | 102 | 66 | 146 | f |
128 | | 103 | 67 | 147 | g |
129 | | 104 | 68 | 150 | h |
130 | | 105 | 69 | 151 | i |
131 | | 106 | 6A | 152 | j |
132 | | 107 | 6B | 153 | k |
133 | | 108 | 6C | 154 | l |
134 | | 109 | 6D | 155 | m |
135 | | 110 | 6E | 156 | n |
136 | | 111 | 6F | 157 | o |
137 | | 112 | 70 | 160 | p |
138 | | 113 | 71 | 161 | q |
139 | | 114 | 72 | 162 | r |
140 | | 115 | 73 | 163 | s |
141 | | 116 | 74 | 164 | t |
142 | | 117 | 75 | 165 | u |
143 | | 118 | 76 | 166 | v |
144 | | 119 | 77 | 167 | w |
145 | | 120 | 78 | 170 | x |
146 | | 121 | 79 | 171 | y |
147 | | 122 | 7A | 172 | z |
148 | | 123 | 7B | 173 | { |
149 | | 124 | 7C | 174 | \| |
150 | | 125 | 7D | 175 | } |
151 | | 126 | 7E | 176 | ~ |
152 | | 127 | 7F | 177 | DEL |
153 |
--------------------------------------------------------------------------------
/static/cheatsheet/strings.md:
--------------------------------------------------------------------------------
1 | # Strings Cheatsheet
2 |
3 | - [Strings Cheatsheet](#strings-cheatsheet)
4 | - [String Basics](#string-basics)
5 | - [String Indexes](#string-indexes)
6 | - [Important Functions](#important-functions)
7 | - [Function Examples](#function-examples)
8 | - [Conversions](#conversions)
9 | - [Links](#links)
10 |
11 | ## String Basics
12 |
13 | Strings are **immutable** (cannot change)
14 | Strings are **objects** (not primatives)
15 |
16 | ``` javascript
17 | // Creation
18 | String s = "Hello, World!";
19 | s = "Change the value";
20 | String s = new String("Hello, World");
21 | // Concatination
22 | s = s + "Addition";
23 | ```
24 |
25 | ## String Indexes
26 |
27 | Indexes start at `0`
28 |
29 | | String | H | e | l | l | o |
30 | | ------ | --- | --- | --- | --- | --- |
31 | | Index | 0 | 1 | 2 | 3 | 4 |
32 |
33 | ## Important Functions
34 |
35 | | Function Name | Parameter List | Return |
36 | | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
37 | | `s.length()` | | `int`: the length of the string |
38 | | `s.substring()` | `int start`: Start index of your substring `int end` End index of your substring | `String`: A substring of `s` from indecies `start` to `end - 1` |
39 | | `s.substring()` | `int start`: Start index of your substring | `String`: A substring for index `start` to the end of the string |
40 | | `s.indexOf()` | `String str`: String to search for within the string | `int`: if `str` is found inside `s`, then it gives the index where it is found, if not returns `-1` |
41 | | `s.indexOf()` | `String str`: String to search for within the string `int i`: Index to start your search | `int`: if `str` is found inside `s` after index `i`, then it gives the index where it is found, if not returns `-1` |
42 | | `s.lastIndexOf()` | `String str`: String to search for within the string | `int`: if `str` is found within `s`, it gives the index of the last occurence of that `str`, otherwise returns `-1` |
43 | | `s.charAt()` | `int i`: Index in the string | `char`: Returns the character at index `i` |
44 | | `s.compareTo()` | `String str`: String to compare to | `int`: returns the ascii difference between the first different characters going left to right |
45 | | `s.equals()` | `String other`: String to compare to | `boolean`: `true` if they are equal to one another, `false` otherwise. **Do NOT use ==** |
46 | | `s.equalsIgnoreCase()` | `String other`: String to compare to | `boolean`: `true` if they are equal to one another, ignoring whether or not the letters are uppercase / lowercase, `false` otherwise. **Do NOT use ==** |
47 | | `s.split()` | `String regex`: String to split by | `String[]`: Array with the string broken up by the regex |
48 | | `s.contains()` | `String str`: String to check against | `boolean`: Whether or not `str` appears within `s` |
49 | | `s.startsWith()` | `String str`: String to check against | `boolean`: Whether or not `s` starts with `str` |
50 | | `s.endsWith()` | `String str`: String to check against | `boolean`: Whether or not `s` ends with `str` |
51 | | `s.repeat()` | `int n`: Number of times to repeat the String` | `String`: String containing `n` copies of `s` |
52 | | `s.strip()` | | `String`: `s` that has all trailing or leading whitespace |
53 | | `s.stripLeading()` | | `String`: `s` that has all leading whitespace |
54 | | `s.stripTrailing()` | | `String`: `s` that has all trailing whitespace |
55 | | `s.toCharArray()` | | `char[]`: Character array of all the characters in the string |
56 | | `s.replace()` / `s.replaceFirst()` | Both paramters allow use of regex `String a` or `char a`: String to search for in `s` `String b` or `char b`: String to replace the first instance with. | `String`: String with the first instance of `a` replaced with `b` |
57 | | `s.replaceAll()` | Both paramters allow use of regex `String a` or `char a`: String to search for in `s` `String b` or `char b`: String to replace each instance with. | `String`: String with all instance of `a` replaced with `b` |
58 | | `s.matches()` | `String regex`: Regular Expression to check against | `boolean`: If String `s` is valid for regex `regex` |
59 | | `s.toUpperCase()` | | `String`: `s` with all characters converted to uppercase |
60 | | `s.toLowerCase()` | | `String`: `s` with all characters covnerted to lowercase |
61 | | `s.isEmpty()` | | `boolean`: `true` if `s.length()` is `0`, otherwise `false` |
62 | | `s.isBlank()` | | `boolean`: `true` if `s.strip().length()` is `0`, otherwise `false` |
63 |
64 | ## Function Examples
65 |
66 | ``` java
67 | String s = "Hello";
68 |
69 | out.println(s.length()); // Prints out 5
70 | out.println(s.substring(2, 4)); // Prints out ll
71 | out.println(s.substring(1)); // Prints out ello
72 | out.println(s.indexOf("ll")); // Prints out 2
73 | out.println(s.indexOf("ellooo")); // Prints out -1
74 | out.println(s.indexOf("He", 3)); // Prints out -1
75 | out.println(s.lastIndexOf("l")); // Prints out 3
76 | out.println(s.charAt(3)); // Prints out 3
77 | out.println(s.compareTo("Hello")); // Prints out 0
78 | out.println(s.equals("Hello")); // Prints out true
79 | out.println(s.equals("hello")); // Prints out true
80 | out.println(s == "Hello"); // Prints out false
81 | out.println(s.split("e")); // Prints out ["H", "llo"]
82 | out.println(s.split("")); // Prints out ["H", "e", "l", "l", "o"]
83 | out.println(s.contains("ll")); // Prints out true
84 | out.println(s.startsWith("He")); // Prints out true
85 | out.println(s.endsWith("lo")); // Prints out true
86 | out.println(s.repeat(3)); // Prints out HelloHelloHello
87 | out.println(s.toCharArray()); // Prints out ['H', 'e', 'l', 'l', 'o']
88 | out.println(s.replace("ll", "oo")); // Prints out Heooo
89 | out.println(s.matches(".+")); // Prints out true
90 | out.println(s.toUpperCase()); // Prints out HELLO
91 | out.println(s.toLowerCase()); // Prints out hello
92 | ```
93 |
94 | ## Conversions
95 |
96 | ``` java
97 | String s;
98 | i + ""; // Any number (i) to String
99 | s.charAt(0); // String to char
100 | Integer.parseInt(s); // String to int
101 | Integer.valueOf(s); // String to Integer (class)
102 | String.valueOf(x); // Any primitive (x) to String
103 | ```
104 |
105 | ## Links
106 |
107 | - [Official Strings Documentation](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/String.html)
108 | - [W3 Schools String Reference](https://www.w3schools.com/java/java_ref_string.asp)
109 | - [W3 Schools String Guide](https://www.w3schools.com/java/java_strings.asp)
110 |
--------------------------------------------------------------------------------
/cheatsheet.md:
--------------------------------------------------------------------------------
1 | # Global Cheatsheet
2 |
3 | - [Global Cheatsheet](#global-cheatsheet)
4 | - [Number Bases Cheatsheet](#number-bases-cheatsheet)
5 | - [Common Bases](#common-bases)
6 | - [Letter Representations](#letter-representations)
7 | - [Converting Between Bases](#converting-between-bases)
8 | - [Java Functions](#java-functions)
9 | - [Base Prefixes](#base-prefixes)
10 | - [Twos compilment (Signed values)](#twos-compilment-signed-values)
11 | - [BigO Notation Cheatsheet](#bigo-notation-cheatsheet)
12 | - [Time Complexities (in order from fastest to slowest)](#time-complexities-in-order-from-fastest-to-slowest)
13 | - [`O(1)` - Constant Time](#o1---constant-time)
14 | - [`O(log(n))` - Logarithmic Time](#ologn---logarithmic-time)
15 | - [`O(n)` - Linear Time](#on---linear-time)
16 | - [`O(n*log(n))` - Loglinear Time](#onlogn---loglinear-time)
17 | - [`O(n^2)` - Quadratic Time](#on2---quadratic-time)
18 | - [`O(2^n)` - Exponential Time](#o2n---exponential-time)
19 | - [`O(n!)` - Factorial Time](#on---factorial-time)
20 | - [Links](#links)
21 | - [Math Cheatsheet](#math-cheatsheet)
22 | - [Constants](#constants)
23 | - [Functions](#functions)
24 | - [Function Examples](#function-examples)
25 | - [Random in range](#random-in-range)
26 | - [Links](#links-1)
27 | - [Primitives Cheatsheet](#primitives-cheatsheet)
28 | - [Primitive Types](#primitive-types)
29 | - [Integer Division](#integer-division)
30 | - [Modulus](#modulus)
31 | - [Number Suffixes](#number-suffixes)
32 | - [Default Values](#default-values)
33 | - [Links](#links-2)
34 | - [Strings Cheatsheet](#strings-cheatsheet)
35 | - [String Basics](#string-basics)
36 | - [String Indexes](#string-indexes)
37 | - [Important Functions](#important-functions)
38 | - [Function Examples](#function-examples-1)
39 | - [Conversions](#conversions)
40 | - [Links](#links-3)
41 |
42 |
43 | ## Number Bases Cheatsheet
44 |
45 | ### Common Bases
46 |
47 | | Base ## | | | | | | | | |
48 | | ------- | --- | --- | ------ | ----- | ---- | --- | --- | --- |
49 | | Base 2 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
50 | | Base 8 | | | 32768 | 4096 | 512 | 64 | 8 | 1 |
51 | | Base 10 | | | 100000 | 10000 | 1000 | 100 | 10 | 1 |
52 | | Base 16 | | | | | 4096 | 256 | 16 | 1 |
53 |
54 | ### Letter Representations
55 |
56 | | `A` | `B` | `C` | `D` | `E` | `F` |
57 | | --- | --- | --- | --- | --- | --- |
58 | | 10 | 11 | 12 | 13 | 14 | 15 |
59 |
60 | ### Converting Between Bases
61 |
62 | - Can only only convert between bases that is a power of that base
63 | - Split into block sizes, where `x` is the original base, and `y` is the base to convert to:
64 | - Converting to higher base: `logₓ(y)`
65 | - Converting to lower base: `ʸ√x`
66 | - Blocks form from right to left.
67 | - When converting to a higher base:
68 | - Take each block to base `10`, then put them together.
69 | - When converting to a lower base:
70 | - Take each block and make it into the base you are converting to.
71 | - If necessary, pad each block to the size it must be
72 |
73 | ### Java Functions
74 |
75 | | Function Name | Parameters | Return |
76 | | -------------------------- | ----------------------------------------------------------------- | ------------------------------------------------ |
77 | | `Integer.toString()` | `int num`: Number in base 10 `int radix`: Base to convert to | `String`: Converted Number as a string |
78 | | `Integer.toBinaryString()` | `int num`: Number in base 10 | `String`: Converted Number in Base 2 as a string |
79 |
80 | ### Base Prefixes
81 |
82 | | Base | Prefix |
83 | | ---- | ------ |
84 | | `2` | `0b` |
85 | | `8` | `0` |
86 | | `16` | `0x` |
87 |
88 | ### Twos compilment (Signed values)
89 |
90 | - By default all values in Java are unsigned
91 | - With signed values, make the leftmost value negative:
92 |
93 | | Base ## | | | | | | | | |
94 | | ------- | ---- | --- | --- | --- | --- | --- | --- | --- |
95 | | Base 2 | -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
96 |
97 | ## BigO Notation Cheatsheet
98 |
99 | BigO Notation is a way to determine how fast a program can run, like sorts and searches.
100 | `n` is the number of items in the dataset.
101 |
102 | Each nested for loop adds a power to the complexity. For example, it goes from `n` to `n^2` to `n^3` to `n^4` etc.
103 |
104 | Complexities next to each other are added. For example, a `O(n)` algorithm next to a `O(n^2)` algorithm, the final notation is `O(n + n^2)`.
105 |
106 | > Two `O(1)` algorithms added together are still `O(1)`
107 |
108 | ### Time Complexities (in order from fastest to slowest)
109 |
110 | 
111 |
112 | #### `O(1)` - Constant Time
113 |
114 | This is instant time. This includes things like:
115 |
116 | - Math Equations `(10 + 2)`
117 | - Printing
118 | - Accessing elements of an `Array` / `Arraylist`
119 | - Accessing elements of a `HashMap` / `HashSet`
120 |
121 | #### `O(log(n))` - Logarithmic Time
122 |
123 | This is essentially running a `for i loop` from `0 to n` and another `for loop` running from `i to n`. Includes things such as:
124 |
125 | - Worst Space Complexity of `Quicksort`
126 |
127 | Example:
128 |
129 | ```java
130 | for (int i = 0; i < n; i++)
131 | for (int j = i; j < n; j++)
132 | System.out.println(i + j);
133 | ```
134 |
135 | #### `O(n)` - Linear Time
136 |
137 | A basic `for loop`, where `n` is the number of elements. This includes:
138 |
139 | - Looping over an `Array` / `Arraylist`
140 | - Basic Loop search
141 |
142 | Example:
143 |
144 | ```java
145 | for (int i = 0; i < n; i++)
146 | System.out.println(i);
147 | ```
148 |
149 | #### `O(n*log(n))` - Loglinear Time
150 |
151 | Loglinear time. Includes:
152 |
153 | - Best / Average case `Quicksort`
154 | - Best / Average / Worse case `Mergesort`
155 | - Best / Average / Worse case `Heapsort`
156 |
157 | #### `O(n^2)` - Quadratic Time
158 |
159 | Two `for loops`, each looping from `0 to n`. Includes:
160 |
161 | - Worst case `Quicksort`
162 | - Average / Worst case `Bubble Sort`
163 | - Average / Worst case `Insertion Sort`
164 | - Best / Average / Worst case `Selection Sort`
165 |
166 | Example:
167 |
168 | ```java
169 | for (int i = 0; i < n; i++)
170 | for (int j = 0; j < n; j++)
171 | System.out.println(i + j);
172 | ```
173 |
174 | #### `O(2^n)` - Exponential Time
175 |
176 | Includes things like:
177 |
178 | - Getting Combinations
179 |
180 | #### `O(n!)` - Factorial Time
181 |
182 | Worst time complexity. Includes things like:
183 |
184 | - Traveling Salesman Problem
185 |
186 | ### Links
187 |
188 | - [BigO Examples](https://javachallengers.com/big-o-notation-explanation/)
189 |
190 | ## Math Cheatsheet
191 |
192 | The `Math` class does **not** need to be imported
193 |
194 | ### Constants
195 |
196 | All constants are `doubles`
197 |
198 | | Constant | Value |
199 | | --------- | ----- |
200 | | `Math.PI` | `π` |
201 | | `Math.E` | `E` |
202 |
203 | ### Functions
204 |
205 | > Functions with a type of `number` accept types `double`, `float`, `int`, `long`
206 | > The return type will match the parameter type
207 |
208 | | Function Name | Parameters | Return |
209 | | ------------------ | ------------------------- | --------------------------------------------------- |
210 | | `Math.abs() *` | `number a` | `number`: Absolute Value |
211 | | `Math.pow()` | `double a`, `double b` | `double`: `a` to the power of `b` |
212 | | `Math.sqrt()` | `double a` | `double`: The square root of `a` |
213 | | `Math.cbrt()` | `double a` | `double`: The cube root of `a` |
214 | | `Math.min()` | `number a`, `number b` | `number`: Smallest number between `a` and `b` |
215 | | `Math.max()` | `number a`, `number b` | `number`: Largest number between `a` and `b` |
216 | | `Math.sin()` | `double a` **in radians** | `double`: trigonometric sine of an angle |
217 | | `Math.cos()` | `double a` **in radians** | `double`: trigonometric cosine of an angle |
218 | | `Math.tan()` | `double a` **in radians** | `double`: trigonometric tangent of an angle |
219 | | `Math.toRadians()` | `double a` **in degrees** | `double`: Converts degrees to radians |
220 | | `Math.hypot()` | `double a`, `double b` | `double`: Hypotenuse of a triangle (`sqrt(x2 +y2)`) |
221 | | `Math.floor()` | `double a` | `double`: Truncates `a` |
222 | | `Math.ceil()` | `double a` | `double`: Rounds `a` up to the nearest whole number |
223 | | `Math.round()` | `double a` | `long`: `a` rounded to the nearest whole number |
224 | | `Math.round()` | `float a` | `int`: `a` rounded to the nearest whole number |
225 | | `Math.random()` | | `double`: Random number in the range `0 <= x < 1` |
226 |
227 | ### Function Examples
228 |
229 | ```java
230 | Math.abs(-3) = 3;
231 | Math.pow(7, 2) = 49.0;
232 | Math.sqrt(64) = 8.0;
233 | Math.cbrt(64) = 4.0;
234 | Math.min(2, 4) = 2;
235 | Math.max(2, 4) = 4;
236 | Math.sin(0) = 0.0;
237 | Math.cos(Math.PI) = -1.0;
238 | Math.tan(0) = 0.0;
239 | Math.toRadians(90) = 1.5707;
240 | Math.hypot(3, -4) = 5.0;
241 | Math.floor(4.8) = 4.0;
242 | Math.ceil(4.8) = 5.0;
243 | Math.round(4.5) = 5;
244 | ```
245 |
246 | ### Random in range
247 |
248 | ```java
249 | // Returns a number between min (inclusive) and max (inclusive)
250 | public static randInRange(int min, int max) {
251 | return (int)(Math.random() * ((max - min) + 1)) + min;
252 | }
253 | ```
254 |
255 | ### Links
256 |
257 | - [Math Class Documentation](https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html)
258 |
259 | ## Primitives Cheatsheet
260 |
261 | ### Primitive Types
262 |
263 | | Name | Bits | Signed | Range |
264 | | --------- | ---- | ------ | -------------------------------------------------------- |
265 | | `boolean` | `8` | `No` | `false` or `true` |
266 | | `byte` | `8` | `Yes` | `-128` to `127` |
267 | | `char` | `16` | `No` | `0` to `65535` |
268 | | `short` | `16` | `Yes` | `-32768` to `32767` |
269 | | `int` | `32` | `Yes` | `-2147483648` to `2147483647` |
270 | | `long` | `64` | `Yes` | `-9223372036854775808` to `9223372036854775807` |
271 | | `float` | `32` | | `1.40239846e-45` to `3.40282347e+38` |
272 | | `double` | `64` | | `4.94065645841246544e-324` to `1.79769313486231570e+308` |
273 |
274 | ### Integer Division
275 |
276 | - Division between two `number` values (`byte`, `short`, `int`, `long`) will truncate the decimal.
277 | - Division between a decimal value (`float`, `double`) and a `number` value will produce a decimal.
278 |
279 | ```java
280 | 2 / 3 = 0
281 | 16 / 5 = 3
282 | 8 / 4 = 2
283 | -10 / 7 = -1
284 | 2.0 / 3 = 0.6666
285 | 16 / 5. = 3.2
286 | (double) 1 / 6 = 0.1666
287 | 9d / 4 = 2.25
288 | ```
289 |
290 | ### Modulus
291 |
292 | - `%` symbol takes the remainder
293 |
294 | ```java
295 | 16 % 2 == 0;
296 | x % 2 == 0; // Is x even?
297 | x % 3 != 0; // Is x NOT a multiple of 3
298 | ```
299 |
300 | ### Number Suffixes
301 |
302 | Certain Data types have suffixes that specify what type they are.
303 | **Not using these may cause errors**
304 |
305 | ```java
306 | long l = 12345L;
307 | float f = 100.123f;
308 | double d = 9876.12345d;
309 | ```
310 |
311 | ### Default Values
312 |
313 | If no value is specified, the types will default to:
314 |
315 | | Data Type | Default Value |
316 | | ---------------------- | ------------- |
317 | | `byte`, `short`, `int` | `0` |
318 | | `float` | `0f` |
319 | | `double` | `0d` |
320 | | `long` | `0L` |
321 | | `char` | `'\u0000'` |
322 | | `Object` | `null` |
323 | | `boolean` | `false` |
324 |
325 | ### Links
326 |
327 | - [Official Primitives Guide](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html)
328 | - [W3 Schools Data Types Guide](https://www.w3schools.com/java/java_data_types.asp)
329 |
330 | ## Strings Cheatsheet
331 |
332 | ### String Basics
333 |
334 | Strings are **immutable** (cannot change)
335 | Strings are **objects** (not primatives)
336 |
337 | ```java
338 | // Creation
339 | String s = "Hello, World!";
340 | s = "Change the value";
341 | String s = new String("Hello, World");
342 | // Concatination
343 | s = s + "Addition";
344 | ```
345 |
346 | ### String Indexes
347 |
348 | Indexes start at `0`
349 |
350 | | String | H | e | l | l | o |
351 | | ------ | --- | --- | --- | --- | --- |
352 | | Index | 0 | 1 | 2 | 3 | 4 |
353 |
354 | ### Important Functions
355 |
356 | | Function Name | Parameter List | Return |
357 | | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
358 | | `s.length()` | | `int`: the length of the string |
359 | | `s.substring()` | `int start`: Start index of your substring `int end` End index of your substring | `String`: A substring of `s` from indecies `start` to `end - 1` |
360 | | `s.substring()` | `int start`: Start index of your substring | `String`: A substring for index `start` to the end of the string |
361 | | `s.indexOf()` | `String str`: String to search for within the string | `int`: if `str` is found inside `s`, then it gives the index where it is found, if not returns `-1` |
362 | | `s.indexOf()` | `String str`: String to search for within the string `int i`: Index to start your search | `int`: if `str` is found inside `s` after index `i`, then it gives the index where it is found, if not returns `-1` |
363 | | `s.lastIndexOf()` | `String str`: String to search for within the string | `int`: if `str` is found within `s`, it gives the index of the last occurence of that `str`, otherwise returns `-1` |
364 | | `s.charAt()` | `int i`: Index in the string | `char`: Returns the character at index `i` |
365 | | `s.compareTo()` | `String str`: String to compare to | `int`: returns the ascii difference between the first different characters going left to right |
366 | | `s.equals()` | `String other`: String to compare to | `boolean`: `true` if they are equal to one another, `false` otherwise. **Do NOT use ==** |
367 | | `s.equalsIgnoreCase()` | `String other`: String to compare to | `boolean`: `true` if they are equal to one another, ignoring whether or not the letters are uppercase / lowercase, `false` otherwise. **Do NOT use ==** |
368 | | `s.split()` | `String regex`: String to split by | `String[]`: Array with the string broken up by the regex |
369 | | `s.contains()` | `String str`: String to check against | `boolean`: Whether or not `str` appears within `s` |
370 | | `s.startsWith()` | `String str`: String to check against | `boolean`: Whether or not `s` starts with `str` |
371 | | `s.endsWith()` | `String str`: String to check against | `boolean`: Whether or not `s` ends with `str` |
372 | | `s.repeat()` | `int n`: Number of times to repeat the String` | `String`: String containing `n` copies of `s` |
373 | | `s.strip()` | | `String`: `s` that has all trailing or leading whitespace |
374 | | `s.stripLeading()` | | `String`: `s` that has all leading whitespace |
375 | | `s.stripTrailing()` | | `String`: `s` that has all trailing whitespace |
376 | | `s.toCharArray()` | | `char[]`: Character array of all the characters in the string |
377 | | `s.replace()` / `s.replaceFirst()` | Both paramters allow use of regex `String a` or `char a`: String to search for in `s` `String b` or `char b`: String to replace the first instance with. | `String`: String with the first instance of `a` replaced with `b` |
378 | | `s.replaceAll()` | Both paramters allow use of regex `String a` or `char a`: String to search for in `s` `String b` or `char b`: String to replace each instance with. | `String`: String with all instance of `a` replaced with `b` |
379 | | `s.matches()` | `String regex`: Regular Expression to check against | `boolean`: If String `s` is valid for regex `regex` |
380 | | `s.toUpperCase()` | | `String`: `s` with all characters converted to uppercase |
381 | | `s.toLowerCase()` | | `String`: `s` with all characters covnerted to lowercase |
382 | | `s.isEmpty()` | | `boolean`: `true` if `s.length()` is `0`, otherwise `false` |
383 | | `s.isBlank()` | | `boolean`: `true` if `s.strip().length()` is `0`, otherwise `false` |
384 |
385 | ### Function Examples
386 |
387 | ```java
388 | String s = "Hello";
389 |
390 | out.println(s.length()); // Prints out 5
391 | out.println(s.substring(2, 4)); // Prints out ll
392 | out.println(s.substring(1)); // Prints out ello
393 | out.println(s.indexOf("ll")); // Prints out 2
394 | out.println(s.indexOf("ellooo")); // Prints out -1
395 | out.println(s.indexOf("He", 3)); // Prints out -1
396 | out.println(s.lastIndexOf("l")); // Prints out 3
397 | out.println(s.charAt(3)); // Prints out 3
398 | out.println(s.compareTo("Hello")); // Prints out 0
399 | out.println(s.equals("Hello")); // Prints out true
400 | out.println(s.equals("hello")); // Prints out true
401 | out.println(s == "Hello"); // Prints out false
402 | out.println(s.split("e")); // Prints out ["H", "llo"]
403 | out.println(s.split("")); // Prints out ["H", "e", "l", "l", "o"]
404 | out.println(s.contains("ll")); // Prints out true
405 | out.println(s.startsWith("He")); // Prints out true
406 | out.println(s.endsWith("lo")); // Prints out true
407 | out.println(s.repeat(3)); // Prints out HelloHelloHello
408 | out.println(s.toCharArray()); // Prints out ['H', 'e', 'l', 'l', 'o']
409 | out.println(s.replace("ll", "oo")); // Prints out Heooo
410 | out.println(s.matches(".+")); // Prints out true
411 | out.println(s.toUpperCase()); // Prints out HELLO
412 | out.println(s.toLowerCase()); // Prints out hello
413 | ```
414 |
415 | ### Conversions
416 |
417 | ```java
418 | String s;
419 | i + ""; // Any number (i) to String
420 | s.charAt(0); // String to char
421 | Integer.parseInt(s); // String to int
422 | Integer.valueOf(s); // String to Integer (class)
423 | String.valueOf(x); // Any primitive (x) to String
424 | ```
425 |
426 | ### Links
427 |
428 | - [Official Strings Documentation](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/String.html)
429 | - [W3 Schools String Reference](https://www.w3schools.com/java/java_ref_string.asp)
430 | - [W3 Schools String Guide](https://www.w3schools.com/java/java_strings.asp)
431 |
--------------------------------------------------------------------------------