\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{solisoleille (soleille01)} \pdfinfo{ /Title (java-beginner-syntax.pdf) /Creator (Cheatography) /Author (solisoleille (soleille01)) /Subject (Java - Beginner Syntax 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}{FC9677} \definecolor{LightBackground}{HTML}{FEF1EE} \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 - Beginner Syntax Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{solisoleille (soleille01)} via \textcolor{DarkBackground}{\uline{cheatography.com/130728/cs/31370/}}} \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}solisoleille (soleille01) \\ \uline{cheatography.com/soleille01} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 4th June, 2022.\\ 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}{p{0.74655 cm} x{4.23045 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Primitive data types}} \tn % Row 0 \SetRowColor{LightBackground} int & Main type for storing whole numbers/integers. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} float & Denotes real numbers with a smaller range and precision. Sufficient for storing 6 to 7 decimal digits. Precision is about 15 decimal digits. \tn % Row Count 7 (+ 5) % Row 2 \SetRowColor{LightBackground} \seqsplit{double} & Main type for real numbers. Sufficient for storing 15 decimal digits. \tn % Row Count 10 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{boolean} & Stores only two possible values: true or false. Used to represent any binary situation, used mainly for recording decisions. \tn % Row Count 14 (+ 4) % Row 4 \SetRowColor{LightBackground} char & Stores a single character/letter. Represents all types of characters, including: Letters, formatting characters, special characters, and characters in other languages. Characters are written in single quotes. \tn % Row Count 21 (+ 7) % Row 5 \SetRowColor{white} byte & Stores whole numbers from -128 to 127. \tn % Row Count 23 (+ 2) % Row 6 \SetRowColor{LightBackground} short & Stores whole numbers from -32,768 to 32,767. Can store only less than int. \tn % Row Count 26 (+ 3) % Row 7 \SetRowColor{white} long & Stores whole numbers from about -(9e+18) to (9e+18). Can store more than int. \tn % Row Count 29 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Primitive data types:}} A primitive data type specifies the size and type of variable values, and it has no additional methods.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Comments}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Single line comments: \newline % Row Count 1 (+ 1) `// Comment1` \newline % Row Count 2 (+ 1) {\emph{code}} `// Comment2` \newline % Row Count 3 (+ 1) Multi-line comments: \newline % Row Count 4 (+ 1) /* \newline % Row Count 5 (+ 1) * `Comment` \newline % Row Count 6 (+ 1) * `Continuing comment` \newline % Row Count 7 (+ 1) */% Row Count 8 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Comments:}} Comments are ignored by the computer, they are removed during compilation and exist simply to make the code easier for people to understand.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{General class definition and body}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{public class ClassName \newline \{ \newline Fields \newline Constructors \newline Methods \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Classes:}} Classes describe all objects of a particular kind, and determine the fields, constructors, and methods these specific instances will all have. \newline {\bf{Class names:}} By convention, class names start with an uppercase letter (to distinguish from other names like variables and methods.{\bf{ \newline }}Classes and types:** A class name can be used as the type for a variable. Variables that have a class as their type can store references to objects belonging to that class} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{General constructor definition and body}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{public class ClassName \newline \{ \newline {\emph{Fields omitted}} \newline \newline public ClassName(paramtype paramname, {\emph{etc.}}) \newline \{ \newline fieldName = fieldValue1; \newline fieldName2 = fieldValue2; \newline fieldName3 = paramname; \newline -{}-{}-{\emph{etc.}} \newline \} \newline \newline {\emph{Methods omitted}} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Constructors:}} Constructors are responsible for ensuring that an object is set up properly when it is first created/that an object is ready to be used immediately following its creation. \newline {\bf{Initialisation:}} This construction process is also called initialisation. The constructor initialises the fields. \newline {\bf{Note:}} In Java, all fields are automatically initialised to a default value if they are not explicitly initialised (0 for integers etc.)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{General while loops}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{while ({\emph{boolean condition}}) \{ \newline {\emph{loop body}}* \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{While loops:}} A form of indefinite iteration loop. \newline {\bf{Note:}} While the condition evaluates to true, then the body is executed; and once it evaluates to false, the iteration is finished \newline {\bf{Note:}} The condition could evaluate to false on the very first time it is tested. If that happens, the body won't be executed at all. \newline {\bf{Note:}} The while loop does not need to be related to a collection. Even if processing a collection, we do not need to process every element.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{General do-while loops}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{do \{ \newline {\emph{loop body}} \newline \} while ({\emph{boolean condition}});} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Do-while loops:}} A form of indefinite iteration loop, but loop is executed at least once. \newline {\bf{Note:}} While the condition evaluates to true, then the body is executed; and once it evaluates to false, the iteration is finished. \newline {\bf{Note:}} The while loop does not need to be related to a collection. Even if processing a collection, we do not need to process every element.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Other keywords}} \tn % Row 0 \SetRowColor{LightBackground} void & Methods have return types that specify what type of data they return. If a method does not return any specific data, the return type is 'void'. \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} null & Object variables don't always refer to actual objects. When an object variable is first declared, it is initialised to the special value null, which means that the variable isn't pointing to an object. \tn % Row Count 10 (+ 6) % Row 2 \SetRowColor{LightBackground} this & In a 'name overloading' situation where the same variable name is being used for 2 different entities in the same scope, the variable referenced will be the closest defined. To reference the field instead of the paramter write 'this.' before the name. \tn % Row Count 17 (+ 7) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{[}Note to self: these may be sorted later into other groups as I cover more similar material{]}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Casting}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{(newdatatype) value} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Casting:}} Casting means to change a value from one type to a "corresponding" value in another type. \newline {\bf{Note:}} We can cast char values to their Unicode int values and vice versa.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.23965 cm} x{2.73735 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Math}} \tn % Row 0 \SetRowColor{LightBackground} Math.abs & Absolute value \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Math.pow & Raise to the power/ exponents \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} Math.max; Math.min & Find the maximum; Find the minimum \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} Math.sin; Math.cos; Math.tan & Trigonometry \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} Math.round & Round number \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} Math.PI; Math.E & Use constants of Pi and E \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Math:}} Math defines pretty much all mathematical functionality that you will ever need. \newline {\bf{Note:}} It has other methods that are not stated here. \newline {\bf{Note:}} All of the methods in Math are static methods.} \tn \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}{Changes to parameters, equality over objects}} \tn % Row 0 \SetRowColor{LightBackground} Method with primitive type parameter & Updates to that parameter are local only. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Method with object type parameter (e.g. array) & Parameter is a new variable but refers to the same object; changes are persistent. \tn % Row Count 8 (+ 5) % Row 2 \SetRowColor{LightBackground} Equality over arrays and objects & True if the variables point to the same object, false if not even if the contents of the objects are the same. \tn % Row Count 14 (+ 6) % Row 3 \SetRowColor{white} \seqsplit{java.util.Arrays.equals(object1}, object2) & True if the variables point to the same objects and also if the contents of different objects are the same. \tn % Row Count 20 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Final variables}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{private final datatype variableName = variableValue; OR \newline private static final datatype variableName = variableValue} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Final variables:}} Final variables must be initialised immediately and can never be changed.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Throwing unchecked exceptions}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{public returntype methodName(paramtype paramvalue {\emph{etc.}}) \{ \newline {\emph{code body}} \newline if boolean\_exception \{ \newline throw new ExceptionName ("exception message") \newline \} \newline {\emph{code body}} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Unchecked exceptions:}} When an exception is thrown and it is an unchecked exception, the system halts with an error message. It is a standardized way to deal with errors to provide informative feedback. \newline {\bf{Error type:}} Used with client code is seriously wrong - attempts to use your methods incorrectly by passing incorrect parameter values.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.89586 cm} x{4.08114 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Object data types}} \tn % Row 0 \SetRowColor{LightBackground} String & Used to represent a sequence of characters, including: names, addresses, general text etc. Strings are written in double quotes. \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \seqsplit{ArrayList} & A Java class from the java.util package. \tn % Row Count 6 (+ 2) % Row 2 \SetRowColor{LightBackground} Random & A java class from the java.util package \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Object data types:}} Data types that are actually objects, which contain methods that can be called to perform certain operations on them.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.69678 cm} x{4.28022 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Logical operators}} \tn % Row 0 \SetRowColor{LightBackground} a \&\& b & a and b are both true (and). \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} a || b & At least one of a and b is true (or). \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} !a & a is false/not a (not). \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Precedence:}} \&\& has a higher precedence than ||.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Arithmetic operators}} \tn % Row 0 \SetRowColor{LightBackground} + & Addition - adds together two values. \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} - & Subtraction - subtracts one value from another. \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} * & Multiplication - multiplies two values together. \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} / & Division - divides one value by another. When dividing integers the remainder is truncated (integer division); when dividing doubles the return value is exact. \tn % Row Count 10 (+ 5) % Row 4 \SetRowColor{LightBackground} \% & Modulus - returns the remainder of dividing the one value from another. \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} ++ & Increment - increases the value of the following variable by 1. \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} -{}- & Decrement - decreases the value of the following variable by 1. \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Arithmetic operators:}} Used to perform common mathematical operations. \newline {\bf{Precedence:}} Precedence and associativity are as normal as in maths.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{General method definition and body}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{public class ClassName \newline \{ \newline {\emph{Fields and constructor omitted}} \newline \newline public returntype methodName(paramtype1 paramname1, {\emph{etc.}}) \newline \{ \newline statement1; \newline statement2; \newline {\emph{Body continued}} \newline \} \newline \newline {\emph{Other possible methods omitted}} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Methods:}} Objects have methods that we use to communicate with them. We can use a method to make a change or to get information from the object.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Conditional statements/ if-else-statements}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{if ({\emph{perform some test}}) \{ \newline {\emph{do these statements if the test gave a true result}} \newline \} \newline else if ({\emph{perform some test}}) \{ \newline {\emph{do these statements if the if-statement and else if}} \newline {\emph{-statements above returned false,}} \newline {\emph{but the test for this statement returned true.}} \newline \} \newline else \{ \newline {\emph{do these statements none of the above tests returned true}} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Note:}} It is possible to have only 1 if-statement and no else if or else statements. There can also be many if-statements and else if statements in the same block.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Importing library classes}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{import \seqsplit{librarypackage.ClassName;} OR \newline import librarypackage.*} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Note:}} Usually happens at the very top of the program. \newline {\bf{Note:}} Using * means that all classes in that package is imported. \newline {\bf{Note:}} Some library classes are imported automatically, including Math, String, Integer, Character, Boolean etc.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Creating objects}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Object creation: \newline % Row Count 1 (+ 1) `objectName = new ClassName(paramvalue, {\emph{etc.}});` \newline % Row Count 2 (+ 1) Creating object for field: \newline % Row Count 3 (+ 1) `private ClassName fieldName;` \newline % Row Count 4 (+ 1) ... \newline % Row Count 5 (+ 1) `fieldName = new ClassName(paramvalue, {\emph{etc.}});`% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Note:}} Done in the constructor. Can also create an object assignment to a field, making the field point to the object, but the field variable will have to be declared first \newline {\bf{Note:}} If you haven't called 'new', you haven't created an object.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{General for-each loops}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{for (elementType element : collectionName) \{ \newline {\emph{loop body}} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{For-each loops:}} A type of definite iteration. \newline {\bf{Note:}} For each element in collection, execute loop body. \newline {\bf{Note:}} The new local variable ('element') used to hold the list elements in order is called the 'loop variable' (any name possible). The type of the loop variable must be the same as the declared element type of the collection. \newline {\bf{Note:}} We cannot change what is stored in the collection while iterating, but can change the states of objects already within the collection.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{General for loops}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{for ({\emph{initialisation; boolean condition; post-body action}}) \{ \newline {\emph{loop body}} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{For-each loops:}} A type of indefinite iteration. \newline {\bf{Note:}} For each element in collection, do the things in the loop body. \newline {\bf{Conditionals:}} \seqsplit{Conditionals/if-statements} can be used in loops.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{General JUnit test}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{@Test \newline public void testmethod() \{ \newline {\emph{setup code}} \newline \seqsplit{assertEquals(paramvalues)} \newline \} \newline \newline \textasciicircum{} \newline assertEquals(errorMessage, correctReturn, methodcall) OR \newline assertEquals(errorMessage, correctReturn, methodcall, double) OR \newline assertTrue(errorMessage, correctReturnBoolean) OR \newline assertFalse(errorMessage, correctReturnBoolean)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{JUnit tests}}: JUnit classes run your code and compare actual results with expected results. \newline {\bf{Note}}: Some limitations are that - printing can't be tested; can test only changes to an objects state/values returned by methods; can test only 'public' methods; can't see inside methods.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Static methods}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{public static returntype methodName(paramtype parameter etc.)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Static methods:}} In static methods, the values returned don't depend on the state of an object, only on the arguments provided i.e. you can call a static method without creating an object first. (In fact it is sometimes impossible to create an object) \newline {\bf{Note:}} They are sometimes called class methods. \newline {\bf{Note:}} Can be invoked with the class name, rather than an object name.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Dealing with arrays}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Declaring arrays: \newline % Row Count 1 (+ 1) `datatype{[}{]} arrayName;` OR \newline % Row Count 2 (+ 1) `datatype{[}{]} arrayName = \{variable1, variable2, etc.\};` (array literals) \newline % Row Count 4 (+ 2) `datatype{[}{]}{[}{]} arrayName:` etc. for 2d, 3d + arrays \newline % Row Count 6 (+ 2) Creating arrays: \newline % Row Count 7 (+ 1) `arrayName = new datatype{[}noOfVariables{]};` \newline % Row Count 8 (+ 1) `arrayName = new datatype{[}{]}\{variable1, variable2, etc.\}` (array literals) \newline % Row Count 10 (+ 2) Size of array: \newline % Row Count 11 (+ 1) `arrayName.length` \newline % Row Count 12 (+ 1) Referencing elements: \newline % Row Count 13 (+ 1) `arrayName{[}index{]}`% Row Count 14 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Arrays:}} Arrays are fixed-size collections that can store object references or primitive values. It is an indexed sequence of variables of the same type. \newline {\bf{Note:}} The variables do not have individual names. \newline {\bf{Referencing elements:}} Elements can be used in the same ways and in the same contexts as any other variable of that type. \newline {\bf{Note:}} Arrays can share memory - 'Aliasing'. \newline {\bf{Objects:}} When using an arrays with elements of object type, you also have to populate the array with a loop.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Making assertions}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\emph{code body}} \newline assert booleanCondition : "string"; \newline {\emph{code body}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Assertions:}} A debugging mechanism to use when you are developing complicated code. When the assertion is executed, the boolean condition is evaluated. If it is true, execution continues. If it is false, execution is halted with an (unchecked) AssertionError, and the message string is printed. \newline {\bf{Error types:}} Logic errors. Check what values a given variable has compared to what it should have.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Relational/Comparison operators}} \tn % Row 0 \SetRowColor{LightBackground} == & Equal to \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} != & Not equal to \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \textless{} & Less than \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \textless{}= & Less than or equal to \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \textgreater{} & Greater than \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \textgreater{}= & Greater than or equal to \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Relational operators:}} Operators used to compare two values - usually numbers, but also sometimes other types. \newline {\bf{Precedence:}} All have lower precedence than all arithmetic operators, and higher than all logical operators.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.09494 cm} x{3.88206 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Augmented assignment/ Assignment operators}} \tn % Row 0 \SetRowColor{LightBackground} a += b; & Equivalent to a = a + b; \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} a -= b; & Equivalent to a = a - b; \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} a *= b; & Equivalent to a = a * b; \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} a /= b; & Equivalent to a = a / b; \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} a \%= b; & Equivalent to a = a \% b; \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} a \&= b; & Equivalent to a = a \&\& b; \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} a != b; & Equivalent to a = a || b; \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Augmented assignment:}} Java supports augmented assignment for common arithmetic and logical operators.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{General field definition and body}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{public class ClassName \newline \{ \newline private type fieldName; \newline private type2 fieldName2; \newline -{}-{}-{\emph{etc.}} \newline \newline {\emph{Constructors and methods omitted}} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Fields:}} Fields store data persistently within an object, that have values that can vary over time. Also known as instance variables. Every object will have space for each field declared in its class.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{General variable declaration and assignment}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Field declaration (see other cheat block): \newline % Row Count 1 (+ 1) `private type variableName;` \newline % Row Count 2 (+ 1) Local variable declaration: \newline % Row Count 3 (+ 1) `type variableName;` \newline % Row Count 4 (+ 1) Assignment statement: \newline % Row Count 5 (+ 1) `variableName = newValue;` \newline % Row Count 6 (+ 1) `variableName = 2 * variableName;` \newline % Row Count 7 (+ 1) `variableName = variableName ** 2 + 5;` \newline % Row Count 8 (+ 1) Shorthand (declaration + assignment): \newline % Row Count 9 (+ 1) `type variableName = newValue;`% Row Count 10 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Variables:}} The basic mechanism by which data is organised and stored (long-term, short-term, and communication etc.). Variables must be declared before it is used. \newline {\bf{Variable names:}} Variable names should always start with a lower-case letter. \newline {\bf{Local variables:}} A local variable is defined inside a method body, as opposed to a field variable that is defined outside the method and a parameter that is always defined in the method header.} \tn \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}{Dealing with Strings}} \tn % Row 0 \SetRowColor{LightBackground} "Stringa" + "Stringb" -\textgreater{} "StringaStringb" & String concatenation, achieved with the + operator \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \seqsplit{System.out.print("String")} OR \seqsplit{System.out.println("String")} & String printing. println enters to a new line at the end in addition to displaying the string. \tn % Row Count 8 (+ 5) % Row 2 \SetRowColor{LightBackground} \textbackslash{}n & Prints to a new line. Also known as 'carriage-returns' \tn % Row Count 11 (+ 3) % Row 3 \SetRowColor{white} \textbackslash{}t & Prints the tab character. \tn % Row Count 13 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{String.toLowerCase();} String.toUpperCase(); & Changes all characters in the string to \seqsplit{lowercase/uppercase.} \tn % Row Count 16 (+ 3) % Row 5 \SetRowColor{white} String.length() & Returns the number of characters in the string. \tn % Row Count 19 (+ 3) % Row 6 \SetRowColor{LightBackground} \seqsplit{String.charAt(indexnumber)} & Returns the character at the given index. \tn % Row Count 22 (+ 3) % Row 7 \SetRowColor{white} \seqsplit{String1.compareTo(String2)} & Compares 2 strings. It returns a negative number if the target comes before the argument, a positive number if the target comes after the argument, 0 if they are equal. \tn % Row Count 31 (+ 9) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Strings:}} Strings are used to represent a sequence of characters, including: names, addresses, general text etc. They are written in double quotes. \newline {\bf{Note:}} String is a class defined in the library \newline {\bf{Note:}} Strings in Java are immutable objects (they cannot be changed after they are created). \newline {\bf{Ordering:}} Ordering is by the first letter in which they differ, otherwise by their length. (Note that it is based on Unicode values - not save for case and punctuation etc.)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Method calls}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Internal method calls: \newline % Row Count 1 (+ 1) `methodName(paramvalue1, paramvalue2, {\emph{etc.}})` \newline % Row Count 2 (+ 1) External method calls: \newline % Row Count 3 (+ 1) \seqsplit{`objectName.methodName(paramvalue1}, paramvalue2, {\emph{etc.}})`% Row Count 5 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Internal method calls:}} When an object calls a method on itself. In this case the object name will not need to be specified. \newline {\bf{External method calls:}} When one of the methods of the object in turn calls a method of another object to do part of the task. In this case the object the method is called on needs to be specified.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Dealing with ArrayLists}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Declaring ArrayList field variables: \newline % Row Count 1 (+ 1) `private ArrayList\textless{}type\textgreater{} variableName;` \newline % Row Count 2 (+ 1) Declaring ArrayList local variables: \newline % Row Count 3 (+ 1) `ArrayList\textless{}type\textgreater{} variableName;` \newline % Row Count 4 (+ 1) Creating the collection: \newline % Row Count 5 (+ 1) `variableName = new ArrayList\textless{}\textgreater{}();` \newline % Row Count 6 (+ 1) or `variableName = new ArrayList\textless{}type\textgreater{}();` \newline % Row Count 7 (+ 1) 'add' operation: \newline % Row Count 8 (+ 1) `variableName.add({\emph{expression of the appropriate type}});` \newline % Row Count 10 (+ 2) 'size' operation: \newline % Row Count 11 (+ 1) `variableName.size();` \newline % Row Count 12 (+ 1) 'get' operation: \newline % Row Count 13 (+ 1) `variableName.get({\emph{index}});` \newline % Row Count 14 (+ 1) 'remove' operation: \newline % Row Count 15 (+ 1) `variableName.remove({\emph{index}});`% Row Count 16 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{ArrayList:}} A Java class from the java.util package. Dynamically sized collection, can store both object references or primitive values. \newline {\bf{Operations:}} \newline - add: Adds the written object to the end of the collection. \newline - size: returns an int of the collection size \newline - get: retrieve an item from a specified index \newline - remove: removes an item from a specified index. Will move up the indices of items behind it. \newline {[}- others: search online{]}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Chaining method calls}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\seqsplit{objectName.methodName1().methodName2().methodName3()}.{\emph{etc.}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Note:}} This looks as if methods are calling methods, but the chain of method calls must be read strictly from left to right.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Access modifiers}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Public modifiers: \newline % Row Count 1 (+ 1) `public datatype variableName;` OR \newline % Row Count 2 (+ 1) `public returntype methodName(parameters)` \newline % Row Count 3 (+ 1) Private methods: \newline % Row Count 4 (+ 1) `private datatype variableName;` OR \newline % Row Count 5 (+ 1) `private returntype methodName(parameters)`% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Public methods/variables:}} Public fields, methods and constructors in a class can be accessed/invoked from any class in the program. \newline {\bf{Private methods/variables:}} Private fields, methods and constructors in a class can be accessed/invoked only from the class where it is defined.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Enumerated types}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Creating enum class: \newline % Row Count 1 (+ 1) `public enum ClassName` \newline % Row Count 2 (+ 1) `\{VALUE1,VALUE2, VALUE3, etc...\}` \newline % Row Count 3 (+ 1) Accessing values: \newline % Row Count 4 (+ 1) `ClassName.VALUE` \newline % Row Count 5 (+ 1) Built-in facilities: \newline % Row Count 6 (+ 1) Compared for equality and inequality: `variable1 == variable2` \newline % Row Count 8 (+ 2) Added to strings: `"String" + variable` \newline % Row Count 9 (+ 1) Processed using for-each loop: `for (ClassName variale : ClassName.values()) \{...\}` \newline % Row Count 11 (+ 2) Ordered using ordinal(): variable.ordinal()% Row Count 12 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Enum:}} Used to represent discrete data with only a small number of possible values.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Throwing checked exceptions}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{public returntype methodName(paramtype paramvalue {\emph{etc.}}) throws ExceptionName \{ \newline code body \newline if boolean\_exception \{ \newline throw new ExceptionName ("exception message") \newline \} \newline code body \newline \} \newline \newline // Client code: \newline accessmod returntype anotherMethod(paramtype paramvalue {\emph{etc.}}) \{ \newline try \{ \newline {\emph{code body (for when everything is fine)}} \newline \} \newline catch (ExceptionName e) \{ \newline {\emph{code for when things go wrong}} \newline \} \newline catch (ExceptionName e) \{ \newline {\emph{code for when things go wrong}} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Checked exceptions:}} When an exception is thrown and it is a checked exception, the system tries to find some object in the program able to deal with it without crashing \newline {\bf{Note:}} More complicated than unchecked exceptions - method is required to declare it might throw exceptions; and client code is required to provide code that will be run if so \newline {\bf{Error type:}} Situations that are not entirely unexpected and from which clients may be able to recover.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}