\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Bayan (Bayan.A)} \pdfinfo{ /Title (java-mastery-fundamentals.pdf) /Creator (Cheatography) /Author (Bayan (Bayan.A)) /Subject (Java Mastery - Fundamentals Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{FF8A8A} \definecolor{LightBackground}{HTML}{FFF0F0} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Java Mastery - Fundamentals Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Bayan (Bayan.A)} via \textcolor{DarkBackground}{\uline{cheatography.com/122738/cs/22947/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Bayan (Bayan.A) \\ \uline{cheatography.com/bayan-a} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 11th February, 2021.\\ Updated 24th May, 2020.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{0.89586 cm} x{4.08114 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Primitive Data Types}} \tn % Row 0 \SetRowColor{LightBackground} int & 32-bit \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} long & 64-bit \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} short & 6-bit \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} byte & 8-bit \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} double & double-precision 64-bit \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} float & single-precision 32-bit \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \seqsplit{boolean} & Boolean value (`true or false`) \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} char & 16-bit Unicode character \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.94103 cm} x{3.03597 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Variables/Identifiers}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Start}} with a letter (or\_ or \$)} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Rest {\bf{must}} be letters, \_, \$ or digits} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} Case sensitive & Start with a lower-case letter \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Assignment statement {\bf{replaces the previously}} stored value} \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} Use {\bf{camelCasing}} & thisIsCamelCasing \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Operator Precendence and function}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{From high (16) to low (1)} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{Operator}} & {\bf{Description}} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} (16) {[} {]}, . , () & Access to array element, access to object member, parantheses \tn % Row Count 5 (+ 3) % Row 3 \SetRowColor{white} (15) ++, -{}- & Unary post-increment, unary post-decrement \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} (14) ++, -{}-, +, -, !, \textasciitilde{} & unary pre-increment, unary pre-decrement, unary plus, unary minus, unary logical NOT, unary bitwise NOT \tn % Row Count 12 (+ 5) % Row 5 \SetRowColor{white} (13) (), new & cast, object creation \tn % Row Count 13 (+ 1) % Row 6 \SetRowColor{LightBackground} (12)*, /, \% & multiply, divide, modulus \tn % Row Count 15 (+ 2) % Row 7 \SetRowColor{white} (11)+-, + & additive, string concatenation \tn % Row Count 17 (+ 2) % Row 8 \SetRowColor{LightBackground} (10\textless{}\textless{}, \textgreater{}\textgreater{}, \textgreater{}\textgreater{}\textgreater{} & shift \tn % Row Count 18 (+ 1) % Row 9 \SetRowColor{white} (9) \textless{}, \textless{}=, \textgreater{}, \textgreater{}= & relational; greater than, less than (or equal to) \tn % Row Count 21 (+ 3) % Row 10 \SetRowColor{LightBackground} (8) ==, != & equaly, not equal \tn % Row Count 22 (+ 1) % Row 11 \SetRowColor{white} (7) \& & bitwise AND \tn % Row Count 23 (+ 1) % Row 12 \SetRowColor{LightBackground} (6) \textasciicircum{} & bitwise XOR \tn % Row Count 24 (+ 1) % Row 13 \SetRowColor{white} (5) | & bitwise OR \tn % Row Count 25 (+ 1) % Row 14 \SetRowColor{LightBackground} (4) \&\& & logical AND \tn % Row Count 26 (+ 1) % Row 15 \SetRowColor{white} (3) || & logical OR \tn % Row Count 27 (+ 1) % Row 16 \SetRowColor{LightBackground} (2) ?: & Ternary \tn % Row Count 28 (+ 1) % Row 17 \SetRowColor{white} (1) =, +=, -=, *=, =, /=, \%=, \&= & Assignment \tn % Row Count 30 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.59724 cm} x{4.37976 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Syntax}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{A specific set of rules, using a combination of keywords and other things} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Each {\emph{keyword}} has a spoecific meaning, and sometimes need ot be used in specific orders.} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Case-sensitive. public, Public and PUBLIC are all different} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Semi-colon defines the end of a statement} \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} {\bf{;}} & Must be at the end of every statement \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{class}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Defines a class with the name after the keyword} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Curly braces defines the {\bf{class body}}} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Anything in the curly braces is "part" of this class} \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{note, {\bf{semi-colon is not inserted}} after the class name} \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{`public {\bf{class}} Hello `\{ \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.64241 cm} x{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Access Modifiers}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{These are java keywords} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Allows defining the scope, how other parts of the code can access this code} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{Access Modifiers}} & {\bf{Access Levels}} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} public & Same Class, same package, other subclass, other package \tn % Row Count 8 (+ 3) % Row 4 \SetRowColor{LightBackground} protected & Same Class, same package, other subclass \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} no access modifier & Same Class, same package \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} private & Same Class \tn % Row Count 13 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Access to members permitted by each modifier} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Method}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Collection of statements that perform an operation} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{main method}} & Entry point of any Java code \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} void & Java keyword \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} & Indicates method returns nothing \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} ( ) & {\bf{mandatory}} method declaration \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} & can include 1 or more parameters \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} \{ \} & {\bf{Code block}} \tn % Row Count 11 (+ 1) % Row 7 \SetRowColor{white} & Mandatory in a method declaration \tn % Row Count 13 (+ 2) % Row 8 \SetRowColor{LightBackground} & Defines start and end of method \tn % Row Count 15 (+ 2) % Row 9 \SetRowColor{white} & Place statements to perform tasks \tn % Row Count 17 (+ 2) % Row 10 \SetRowColor{LightBackground} {\bf{Statement}} & Complete command to be executed \tn % Row Count 19 (+ 2) % Row 11 \SetRowColor{white} & Can include more than one expressions \tn % Row Count 21 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{`public static void main(String{[}{]} args)` \{ \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Variables}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Way to store information} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Accessed via name given} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Can be changed} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} Must define the variables type of data & known as {\bf{Data Types}} \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Must initialise before use} \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} Declaration Statement & Specify data type, then varaiable name \tn % Row Count 8 (+ 2) % Row 6 \SetRowColor{LightBackground} & optionally, add an expression to intialise a value \tn % Row Count 11 (+ 3) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Data types do not form part of the expression} \tn % Row Count 12 (+ 1) % Row 8 \SetRowColor{LightBackground} Example: `int myNumber = 50` & `{\bf{myNumber = 50}}` is the expression, {\bf{not}} `int` \tn % Row Count 15 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4177 cm} x{1.16956 cm} x{1.29487 cm} x{1.29487 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{5.377cm}}{\bf\textcolor{white}{Literals}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Boolean} & `true` represents a true boolean value & & \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} & `false` represents a false boolean value & & \tn % Row Count 8 (+ 4) % Row 2 \SetRowColor{LightBackground} \seqsplit{String} data & {\bf{"string"}} & Sequence of characters (including Unicode) & \tn % Row Count 12 (+ 4) % Row 3 \SetRowColor{white} \seqsplit{Numeric} & There are three main types: int, double, char & & \tn % Row Count 17 (+ 5) % Row 4 \SetRowColor{LightBackground} & `int` & integer & Whole \seqsplit{number(without} decimal points) \tn % Row Count 21 (+ 4) % Row 5 \SetRowColor{white} & `double` & Floating point & decimal fractions / exponential notation \tn % Row Count 25 (+ 4) % Row 6 \SetRowColor{LightBackground} & `char` & character & Stores the 16-bit Unicode integer value of the character in question. \tn % Row Count 31 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.74195 cm} x{3.23505 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Operand}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Describes any object manipulated by an operator} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `int myVar = 15 + 12;` & `+` is the operator\{\{nl\}\}`15` and `12` are the operands \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} & Variables instead of literals are also operands \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.74195 cm} x{3.23505 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Expression}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Combination of variables, literals, method return values, and operators} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Variable assignment without the data type declaration, or the string in " " being printed, and {\bf{not}} the semi-colon} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Examples:}}} \tn % Row Count 6 (+ 1) % Row 3 \SetRowColor{white} `int myVar = 15 + 12;` & `15 + 12` is the expression \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} & same if variables replace number literals \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{`int myVariable= 50;`} \tn % Row Count 11 (+ 1) % Row 6 \SetRowColor{LightBackground} `myVariable= 50` & Expression \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{`System.out.println("Random} string");`} \tn % Row Count 14 (+ 1) % Row 8 \SetRowColor{LightBackground} `"Random string"` & Expression \tn % Row Count 16 (+ 2) % Row 9 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{`if(myVariable \textgreater{} 50)`} \tn % Row Count 17 (+ 1) % Row 10 \SetRowColor{LightBackground} `myVariable \textgreater{} 50` & Expression \tn % Row Count 19 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.9816 cm} x{0.9954 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Expressions and Statements}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{A {\bf{statement}} is the entire code, from data type declaration, ending at the semi-colon,} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `int myVariable= 50;` & \seqsplit{Statement} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{`System.out.println("random} string"); & \seqsplit{Statement} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} `myVariable++` & \seqsplit{Statement} \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.68655 cm} x{2.83774 cm} x{1.05271 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Wrapper Class Limit}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Can be experienced by all primitve data types} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \seqsplit{Overflow} & Putting too large a number allocated by the computer for an integer & \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} e.g. & `Integer.MAX\_VALUE + 1 =` & \seqsplit{`-2147483648`} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{Underflow:} & Putting too small a number allocated by the computer for an integer & \tn % Row Count 9 (+ 3) % Row 4 \SetRowColor{LightBackground} e.g & `Integer.MIN\_VALUE - 1 =` & \seqsplit{`2147483647`} \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Going past a limit on either side(max/min) often results in cycling to opposite side. i.e. less than the min cycles to the max, and more than max cycles to the min} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.55618 cm} x{1.51041 cm} x{1.51041 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Integer (Wrapper Class)}} \tn % Row 0 \SetRowColor{LightBackground} Occupies 32 bits & has a width of 32 & \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `Integer` & Gives ways to perform operations on an `int` & \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} int numbers can be written with \_ for readability & e.g. \seqsplit{2\_147\_483\_647} & (version 7 or higher) \tn % Row Count 10 (+ 4) % Row 3 \SetRowColor{white} & \seqsplit{`Integer.MAX\_VALUE`} & -2147483648 \tn % Row Count 12 (+ 2) % Row 4 \SetRowColor{LightBackground} & \seqsplit{`Integer.MAX\_VALUE`} & 2147483647 \tn % Row Count 14 (+ 2) % Row 5 \SetRowColor{white} A whole number & Doesn't handle the remainders & e.g.\{\{nl\}\} `int myInt = 5 / 2;`\{\{nl\}\} myInt = 2 \tn % Row Count 18 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.14425 cm} x{2.97505 cm} p{0.4577 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Byte (Wrapper Class)}} \tn % Row 0 \SetRowColor{LightBackground} Occupies 8 bits & "byte has a width of 8" & \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `byte` & Mostly used as documentation to show it is small & \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} & Smaller data type takes less space and provides quicker access & \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} & e.g. `byte myMinByteValue =` & -128 \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} & `byte myMaxByteValue = ` & 127 \tn % Row Count 10 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Not used as often, due to computers today having more space.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.64772 cm} x{2.2885 cm} p{0.64078 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Short - Wrapper Class}} \tn % Row 0 \SetRowColor{LightBackground} Occupies 16 bits & "has a width of 16" & \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{`short`} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} & e.g. `Short.MIN\_VALUE` & \seqsplit{-32768} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} & e.g. `Short.MAX\_VALUE` & 32767 \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.59264 cm} x{3.38436 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Long (Wrapper Class)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Used for an integer larger than the amount an `int` can store} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Has a width of 64 & can store 2 to the power of 63 \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Long variables require an uppercase "L" at the end of a number} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} & e.g. `myLongValue = 100L;` \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} & Otherwise, it is treated as an `int` \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.53827 cm} x{2.43873 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Single and Double Precision}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Refers to format and space occupied by type.} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{Single Precision}} & {\emph{Has a width of 32}} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} & (Occupies 32 bits) \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} {\bf{Double Precision}} & {\emph{Has a width of 64}} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} & (Occupies 64 bits) \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Floating Point Numbers}} \tn % Row 0 \SetRowColor{LightBackground} `float` & `float myFloatValue = 5.25f;` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} & By default, Java assumes it's a `double`, requiring the `f` after the number \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} Unlike whole numbers & Has fractional parts expressed with a decimal point \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} & e.g. 3.14159 \tn % Row Count 10 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Also known as "real numbers"} \tn % Row Count 11 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Used for more precise calculations} \tn % Row Count 12 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Aren't recommended to use much these days} \tn % Row Count 13 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{A {\bf{single precision number}}} \tn % Row Count 14 (+ 1) % Row 8 \SetRowColor{LightBackground} Smaller and less precise than Double & Range: 1.4E to 3.4028235E+38 \tn % Row Count 16 (+ 2) % Row 9 \SetRowColor{white} Requires less memory & 32 bits / 4 bytes \tn % Row Count 18 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Double}} \tn % Row 0 \SetRowColor{LightBackground} `double` & `double myDoubleValue = 5.25d;` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{A {\bf{Double Precision Number}}} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} Requires more memory & 64 bits / 8 bytes \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} Larger range and more precise than Single & Range: 4.9E-324 to \seqsplit{1.7976931348623157E+308} \tn % Row Count 7 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{char}} \tn % Row 0 \SetRowColor{LightBackground} `char` & `char myChar = 'D';` \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Stores only 1 character & \textgreater{}1 character prompts an error \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Single ' used, not like that used for "strings"} \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} Occupies 16 bits & "width of 15" \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} & Not a single byte, as it allows to store Unicode characters \tn % Row Count 8 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Used to store data in arrays} \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} Using Unicode, `\textbackslash{}u` must be before the specific code is used & `char myUnicodeChar = '\textbackslash{}0044';` \{\{nl\}\} Displays "D" \tn % Row Count 12 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Unicode}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{International encoding standard} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Use with different languages \& scripts} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Each letter, digits, or symbol is assigned a {\bf{unique numeric value}}} \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{This value applies accross different platforms and programs} \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Allows representation of different languages} \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} Can represent any one of 65535 different types of characters & via combination of two bytes in memory \tn % Row Count 10 (+ 3) % Row 6 \SetRowColor{LightBackground} Full list of unicode characters: & \seqsplit{www.unicode-table.com/en/\#control-character} \tn % Row Count 13 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.93643 cm} x{2.04057 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Boolean}} \tn % Row 0 \SetRowColor{LightBackground} Allows only two choices & `true` or `false` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Variable names commonly written as a question & `boolean isJavaEasy = true;` \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{String}} \tn % Row 0 \SetRowColor{LightBackground} A datatype that is NOT a primitive type & Actually a {\bf{Class}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} A sequence of characters & Can contain a single character \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} & `String myString = "This is a string";` \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Can use Unicode characters & `String myString + "\textbackslash{}u00A9 2019";` \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} Treats texts or digits typed as text only & No numerical calculations are done. \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} String variables added with another variable append them only & `String myNumber = "250";\{\{nl\}\} String yourNumber = "654"; \{\{nl\}\} myNumber + yourNumber = 250654` \tn % Row Count 16 (+ 5) % Row 6 \SetRowColor{LightBackground} Strings are immutable & Can't be changed after created \tn % Row Count 18 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Code Blocks}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Variables that exist outside the code block can be accessed inside the code block} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{But}} variables created within an if statement are deleted once the program leaves the code block} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{e.g.:} \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{`int score = 10 \{\{nl\}\}if(gameOver) \{ \{\{nl\}\} ~ int finalScore = score + bonus; \{\{nl\}\} \} \{\{nl\}\} int saveScore = finalScore;`} \tn % Row Count 8 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{The final line of code would produce an error, because finalScore only exists within the if code block} \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{The concept of variables inside a code block is called {\bf{Scope}}} \tn % Row Count 13 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.96117 cm} x{2.7462 cm} x{0.86963 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Arithmetic Operators}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Name}} & {\bf{Example}} & \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \seqsplit{Addition} & `int result = 1 + 2;` & \seqsplit{`result`} = 3 \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{Subtraction} & `result = result - 1; // 3 - 1` & \seqsplit{`result`} = 2 \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{Multiplication} & `result = result {\emph{ 10; //2 }} 10` & \seqsplit{`result`} = 20 \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{Division} & `result = result / 5; //20 / 5` & \seqsplit{`result`} = 4 \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} Modulus \% & `result = result \% 3; \{\{nl\}\}//remainder of (4 \% 3)` & \seqsplit{`result`} = 1 \tn % Row Count 12 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Modulus(aka remainder) retains the remainder of two operands} \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.03597 cm} x{1.94103 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Operator Abbreviation}} \tn % Row 0 \SetRowColor{LightBackground} Original & Abbreviated \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `result = result + 1;` & `result++;` \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `result = result - 1;` & `result-{}-;` \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} `result = result + 2;` & `result += 2;` \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} `result = result * 10;` & `result *= 10;` \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} `result = result / 3;` & `result /= 3;` \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} `result = result - 2;` & `result -= 2;` \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{if-then}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Conditional Logic}} & Checks a condition, executing code based on whether the condition(or expression) is true or false \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Executing a section only if a particular test evaluates to true} \tn % Row Count 7 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{No `;` after if parentheses} \tn % Row Count 8 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{`boolean isAlien = false; \{\{nl\}\} if (isAlien == false) \{ \{\{nl\}\} System.out.println("It is not an alien!");\{`} \tn % Row Count 11 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Use curly brackets if executing a code block} \tn % Row Count 12 (+ 1) % Row 5 \SetRowColor{white} `==` tests if operands are identical & "Does `isAlien` equal or have the value `false`\{\{nl\}\} The expression `is isAlien false` is true \tn % Row Count 17 (+ 5) % Row 6 \SetRowColor{LightBackground} & it would return `false` if they are NOT equal \tn % Row Count 20 (+ 3) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{`if` keyword determines if the expression in the parenthesis evaluates to true, only then executing the next line of code.} \tn % Row Count 23 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.88206 cm} p{1.09494 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Logical AND}} \tn % Row 0 \SetRowColor{LightBackground} Symbol: & \&\& \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Returns the boolean value {\bf{`true`}} if both operands are `true` and returns `false` otherwise.} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Example:}}} \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{`topScore = 80` \{\{nl\}\} `secondTopScore = 60` \{\{nl\}\} `if ((topScore \textgreater{} secondTopScore) \&\& (topScore \textless{} 100))`} \tn % Row Count 7 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Breakdown:}}} \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{if ( (topScore is greater than secondTopScore) AND (topScore is less than 100) )} \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{if ( ( true ) AND ( true ) )} \tn % Row Count 11 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{both operands are true, therefore the expression is true and will execute the next line} \tn % Row Count 13 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Truth Table: \newline \newline {\bf{p | q | p \&\& q}} \newline T | T | ~ ~ T \newline T | F | ~ ~ F \newline F | T | ~ ~ F \newline F | F | ~ ~ F} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Logical OR}} \tn % Row 0 \SetRowColor{LightBackground} Symbol: & {\bf{| | }} ( two pipe characters) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Either}} or {\bf{both}} conditions must be true for the boolean value to return `true`} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Example:}}} \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{` topScore = 80` \{\{nl\}\}`secondTopScore = 60` \{\{nl\}\} `if ((topScore \textgreater{} 90) || (secondTopScore \textless{}= 90))`} \tn % Row Count 8 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Breakdown:}}} \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{if ( ( topScore is greater than 90) OR ( secondTopScore \textless{}= 90) )} \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} if ( ( `false` ) OR ( `true` ) ) & One operand is `true` \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{boolean value returns `true` and will execute the next line.} \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{True Table \newline \newline {\bf{p}} ~ ~ {\bf{ q}} ~ ~ {\bf{p || q}} \newline T ~ ~ T ~ ~ T \newline T ~ ~ F ~ ~ F \newline F ~ ~ T ~ ~ T \newline F ~ ~ F ~ ~ T} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.55618 cm} x{1.55618 cm} x{1.46464 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Assignment and Equal to Operators}} \tn % Row 0 \SetRowColor{LightBackground} Assignment Operator & & = \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{Assigns value to variable} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{e.g. `int newValue = 50`} \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{In an if expression, it will produce an error as the type required in the if condition is boolean} \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} `if (newValue = 50);` & \seqsplit{`Incompatible} types. \{\{nl\}\}Required {\bf{boolean}} \{\{nl\}\}Found: {\bf{int}} ` & \tn % Row Count 12 (+ 6) % Row 5 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{However, if a boolean is in the if condition, the boolean value can be reassigned. No error will be produced} \tn % Row Count 15 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{} \tn % Row Count 15 (+ 0) % Row 7 \SetRowColor{white} {\bf{Equal to operator}} & & `==` \tn % Row Count 17 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Compares operand values are equal to eachother} \tn % Row Count 18 (+ 1) % Row 9 \SetRowColor{white} e.g. `(50 == 50)` & e.g. (newValue == oldValue) & \tn % Row Count 21 (+ 3) % Row 10 \SetRowColor{LightBackground} `boolean isCar = false; \{\{nl\}\} if (isCar = true) ` & This turns isCar from `false` to `true` & \tn % Row Count 25 (+ 4) % Row 11 \SetRowColor{white} {\bf{Normal:}} & {\bf{Equivalent with NOT operator}} & {\bf{Abbreviations:}} \tn % Row Count 28 (+ 3) % Row 12 \SetRowColor{LightBackground} `if (isCar == true)` & `if(isCar != false)` & `if (isCar)` \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.55618 cm} x{1.55618 cm} x{1.46464 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Assignment and Equal to Operators (cont)}} \tn % Row 13 \SetRowColor{LightBackground} `if (isCar == false)` & `if(isCar != true)` & `if(!isCar)` \tn % Row Count 2 (+ 2) % Row 14 \SetRowColor{white} & & Prevents mistakes and is more concise \tn % Row Count 6 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.62655 cm} x{1.08602 cm} x{1.21133 cm} x{1.2531 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{5.377cm}}{\bf\textcolor{white}{Ternary Operator}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{4}{x{5.377cm}}{A shortcut to assigning one of two values to a variable depending on a given condition} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{4}{x{5.377cm}}{Like an {\bf{if-then-else}} statement} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{4}{x{5.377cm}}{Question mark comes after the condition} \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{4}{x{5.377cm}}{After the question mark, two values that can return are separated by a colon (:)} \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} Takes 3 \seqsplit{operands:} & condition {\bf{?}} & operand1 {\bf{:}} & operand2 \tn % Row Count 9 (+ 3) % Row 5 \SetRowColor{white} & {\bf{Condition}} we're testing against & {\bf{First value}} to assign if first condition was true & {\bf{Second value}} to assign if first condition was false \tn % Row Count 14 (+ 5) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{4}{x{5.377cm}}{Example:} \tn % Row Count 15 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{4}{x{5.377cm}}{`int age = 20`} \tn % Row Count 16 (+ 1) % Row 8 \SetRowColor{LightBackground} \seqsplit{`boolean} \seqsplit{isOver18} =` & `(age == 20) ?` & `true : ` & `false` \tn % Row Count 20 (+ 4) % Row 9 \SetRowColor{white} & is age equal to 20? & if it is, `isOver18= true` & if false, `isOver18 = false` \tn % Row Count 23 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{EXAMPLE CODE}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/bayan-a_1590194028_JavaFundamentalsCODE.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Example code using most concepts outlined in this cheatsheet \newline {\bf{See comments for explanation}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}