-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from frc6506/cheat-sheet-patc
Cheat sheet patc
- Loading branch information
Showing
6 changed files
with
262 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
"declutter", | ||
"gmail", | ||
"Javacademy", | ||
"Javadoc", | ||
"Kanban", | ||
"Libj", | ||
"markdownlint", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
# Java I Cheat Sheet | ||
|
||
## Comments | ||
|
||
<table> | ||
|
||
<tr> | ||
<td>Explanation</td> | ||
<td>Example</td> | ||
</tr> | ||
|
||
<tr> | ||
<td>Single</td> | ||
<td> | ||
|
||
```Java | ||
// comment text | ||
``` | ||
|
||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td>Multiline (Basic)</td> | ||
<td> | ||
|
||
```Java | ||
/* | ||
comment text | ||
*/ | ||
``` | ||
|
||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td>Multiline Javadoc</td> | ||
<td> | ||
|
||
```Java | ||
/** | ||
* comment text | ||
* @author BobSaidHi | ||
*/ | ||
``` | ||
|
||
</td> | ||
</tr> | ||
|
||
</table> | ||
|
||
### Table of Javadoc tags | ||
|
||
[Oracle Docs - Javadoc info](https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html) | ||
|
||
[Complete list](https://www.tutorialspoint.com/java/java_documentation.htm) | ||
|
||
| Tag | Explanation | | ||
|---|---| | ||
| `@author` | Author tag | | ||
| `@version` | Version tag | | ||
| `@param` | Explains one of the method's parameters | | ||
| `@return` | Explains what the method returns | | ||
| `@see` | References more information | | ||
| `@since` | When something was first implemented | | ||
| `@deprecated` | Deprecated tag | | ||
|
||
## Primitives (Basic Variables) | ||
|
||
### Example with an integer | ||
|
||
```Java | ||
// Multiple Statements | ||
int i; | ||
i = 0; | ||
|
||
// Single Statement | ||
int i = 0; | ||
``` | ||
|
||
[Complete List of Primitives](https://en.wikibooks.org/wiki/Java_Programming/Primitive_Types) | ||
|
||
### Table of Primitives | ||
|
||
| Use | Symbol/ Keyword | Explanation | | ||
|---|---|---| | ||
| integer | `int` | Holds a 32-bit integer. There are also other primitives that can hold integers (`byte`, `short`, and `long`). | | ||
| character | `char` | Can hold 1 Unicode character. Can be treated as a special int | | ||
| decimal | `double` | Holds a double precision floating point number, which a way to store a decimal. There are also one other primitives that can hold decimals (`float`). | | ||
| boolean | `boolean` | Holds a boolean value (`true` OR `false`) | | ||
| no return | `void` | In a method declaration, a return type of `void` means that nothing will be returned. | | ||
|
||
> Note: Arrays are indicated with brackets. | ||
## Math Operations | ||
|
||
[Order of operations](https://introcs.cs.princeton.edu/java/11precedence/) | ||
|
||
| Name | Example | Explanation| | ||
|---|---|---| | ||
| Parentheses | `(A)` | A is in parentheses | | ||
| Multiplication | `A * B` | A multiplied by B. | | ||
| Division | `A / B` | A divided by B. | | ||
| Addition | `A + B` | A plus B. | | ||
| Subtraction | `A - B` | A minus B. | | ||
| Modulus | `A%B` | Gives the remainder of `A / B` | | ||
|
||
Also, `+=`, `-=`, `*=`, and `/=` allow one to perform an an operation on a variable then then assigning the result to said variable. | ||
|
||
### Special Loop Operators | ||
|
||
| Example | Action | Explanation | | ||
|---|---|---| | ||
| `A++` | post-increment | | | ||
| `A--` | post-decrement | | | ||
| `++A` | pre-increment | | | ||
| `--A` | pre-decrement | | | ||
|
||
### Math Class | ||
|
||
| Name | Symbol | Explanation| | ||
|---|---|---| | ||
| Exponents | `Math.pow(base, exponent)` | Import the `Math` class by typing `import java.lang.Math`, then... | ||
|
||
## Strings (Fancy Variables) | ||
|
||
A `String` is a special type of variable, because it is actually an object that is implemented as a `char` array. The first character will receive an index of `0`. When you write one, using double quotes, that is called a String literal. [More info](https://docs.oracle.com/javase/tutorial/java/data/strings.html) | ||
|
||
```Java | ||
// Create a String variable from a String literal | ||
String s = "I'm a String"; | ||
|
||
// Create a String using a constructor: | ||
char[] helloArray = { 'h', 'e', 'l', 'l', 'o', '.' }; | ||
String helloString = new String(helloArray); | ||
System.out.println(helloString); | ||
|
||
``` | ||
|
||
[APCSA Java Quick Reference](https://apstudents.collegeboard.org/ap/pdf/ap-computer-science-a-java-quick-reference_0.pdf) | ||
|
||
`String` Methods: | ||
| Method | Explanation | | ||
|---|---| | ||
| `int length()` | Returns the number of characters in a `String` object | | ||
| `String substring(int from, int to)` | Returns the substring beginning at index `from` and ending at index `to - 1` | | ||
| `String substring(int from)` | Returns `substring(from, length())` | | ||
| `int indexOf(String str)` | Returns the index of the first occurrence of `str`; returns `-1` if not found | | ||
| `int compareTo(String other)` | Returns a value `<0` if this is less than `other`; returns `0` if `this` is equal to `other`; returns a value `>0` if `this` is greater than `other` | | ||
|
||
## Print Statements | ||
|
||
[Javadoc for `System.out`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/System.html#out) | ||
|
||
```Java | ||
// Print something out | ||
System.out.print("I'm a String"); | ||
|
||
// Print something out and add a line break | ||
System.out.println("I'm a String"); | ||
|
||
// Concatenating a String and a integer | ||
System.out.println("Five as a number is: " + 5); | ||
|
||
|
||
``` | ||
|
||
> Please note that "I'm a String" (including the quotes) can be replaced by almost anything, including other data types, variables, and even some objects. | ||
## Escape Sequences | ||
|
||
[Further Reading](https://www.informit.com/articles/article.aspx?p=30241&seqNum=3) | ||
|
||
| Sequence | Meaning | | ||
|---|---| | ||
| `\` | Open escape sequence | | ||
| `\t` | tab | | ||
| `\n` | line break (new line) | | ||
| `\"` | Allows the use of double quotes in a String | | ||
| `\'` | Allows the use of a single quot in a char | | ||
| `\\` | Allows the use of a backslash in text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Legacy Tutorials | ||
|
||
> This page references material that may not be supported. | ||
## 6506 Coding Workshops 2019 | ||
|
||
[2019 Code Tutorial Week 1 Presentation](https://docs.google.com/presentation/d/1sOFl91aIioVyXvMVSft5d-G8KnanIeMLz-Xw4ExZkkM/edit?usp=sharing) | ||
|
||
[2019 Code Tutorial Week 2 Presentation](https://docs.google.com/presentation/d/1cXLZEkoNqcRwhaLwBg9RvNKQzxm8zYvOxBlgxwa6Be8/edit?usp=sharing) | ||
|
||
(Other 2019 Presentation lost - contact `x64-bit` or `s3ash3lls`) | ||
|
||
## Breaker Bots (FRC #5104) Javacademy Summer 2019 | ||
|
||
> A few years ago (2019), the Breaker bots from Pacific Grove ran a summer workshop series. These links have been retrieved from emails and the last version (no longer live) of their summer lesson web page, the source of which can be found [here](https://github.com/BreakerBots/Breakersite/blob/c7b93221ee02210e65e9ac10582f90ee2ebe21aa/src/pages/summer_lessons.html). | ||
[(Deprecated) Breaker Bots (FRC #5104) - Javacademy Week 1](https://docs.google.com/presentation/d/1ek36GlI8aiDOuYtB3BftqrIr-H69X6U3gikNIL-Mg4w/edit?usp=sharing) | ||
|
||
[(Deprecated) Breaker Bots (FRC #5104) - Javacademy Exercises - Set 1](https://docs.google.com/document/d/1oTV9E9kgcH1m48e4CjyxbVSXgAg4-E97QX2pgv8VdLM/edit) | ||
|
||
<br> | ||
|
||
[(Deprecated) Breaker Bots (FRC #5104) - Javacademy Practice Solutions](https://github.com/BreakerBots/Javacademy/tree/master/Javacademy%20Week%202) | ||
|
||
[(Deprecated) Breaker Bots (FRC #5104) - Javacademy Week 2](https://docs.google.com/presentation/d/1xgHaPwMhwNigjtHWB4ChHoZXxngItr9LPT5-sfxm09U/edit?usp=sharing) | ||
|
||
<br> | ||
|
||
[Breaker Bots (FRC #5104) - Javacademy Week 3)](https://docs.google.com/presentation/d/1E3z-LQPFoK5SgpAw4g1xmu4TmGPwPASxlpwc1G2MqkQ/edit?usp=sharing) | ||
|
||
[(Deprecated) Breaker Bots (FRC #5104) - Javacademy Exercises - Set 2](https://docs.google.com/document/d/11qnqcND6TGiHUmZ5cNQWMYxvsnx5BEYQp6T0pXQIK3M/edit?usp=sharing) | ||
|
||
<br> | ||
|
||
[(Deprecated) Breaker Bots (FRC #5104) - Week 4 - Cheat Sheet & Projects 1 & 2](https://docs.google.com/document/d/1q7zudOTuQefEMARWO5JlAKtnoUETJOpDzlKEpGZYNRM/edit?usp=sharing) | ||
|
||
<br> | ||
|
||
[(Deprecated) Breaker Bots (FRC #5104) - Javacademy Week 5](https://docs.google.com/presentation/d/1qq5nIkcwCa-6Uu0ksKJAZwR34r0KvhS-AbbyMGg6voY/edit) | ||
|
||
[(Deprecated) Breaker Bots (FRC #5104) - Javacademy Exercises - Set 3](https://docs.google.com/document/d/1xfW6f3-dt7i5oFtpXvCNwyq5msHTBfX6VFE_XgYP5qI/edit?usp=sharing) | ||
|
||
<br> | ||
|
||
[(Deprecated) Breaker Bots (FRC #5104) - Javacademy Week 6)](https://docs.google.com/presentation/d/1cnE6B4xdNqegelAMnZsJawAu-FuBgLgTXQjUIn-zGIA/edit?usp=sharing) | ||
|
||
<br> | ||
|
||
[(Deprecated) Breaker Bots (FRC #5104) - Javacademy Week 7](https://docs.google.com/presentation/d/1N-bDwqEA3dgI9k0X4MwQWSnehP-PS33TcUhUvoRmipU/edit?usp=sharing) | ||
|
||
[(Deprecated) Breaker Bots (FRC #5104) - Javacademy Exercises - Set 4](https://docs.google.com/document/d/1yKloKXCf9H0-YejyF1UdUXh0bWfEv8BZIZbftAv4Gbw/edit?usp=sharing) | ||
|
||
[(Deprecated) Breaker Bots (FRC #5104) - Javacademy Exercises - Set 5)](https://docs.google.com/document/d/1rSFMM3Z19Psa_9JnpJb5y0ro1cQ-5mRCESbax328hcU/edit?usp=sharing) | ||
|
||
<br> | ||
|
||
[(Deprecated) Breaker Bots (FRC #5104) - Javacademy Week 8 - Cheat Sheet 2)](https://docs.google.com/presentation/d/1N-bDwqEA3dgI9k0X4MwQWSnehP-PS33TcUhUvoRmipU/edit?usp=sharing) | ||
|
||
[(Deprecated) Breaker Bots (FRC #5104) - Javacademy Exercises - Set 3)](https://docs.google.com/document/d/1xfW6f3-dt7i5oFtpXvCNwyq5msHTBfX6VFE_XgYP5qI/edit?usp=sharing) | ||
|
||
<br> | ||
|
||
_Updated 20211103T2245 PDT_ |