\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{turback} \pdfinfo{ /Title (java-basics.pdf) /Creator (Cheatography) /Author (turback) /Subject (Java Basics 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}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \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 Basics Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{turback} via \textcolor{DarkBackground}{\uline{cheatography.com/210084/cs/45280/}}} \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}turback \\ \uline{cheatography.com/turback} \\ \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 18th December, 2024.\\ 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*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Variables}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{[} data\_type {]} variable\_name; \newline {[} data\_type {]} variable\_name = initial\_value; \newline \newline int num = 5; \newline \newline double value; \newline value = 22.4;} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{If Statement}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{if ( condition ) \{ \newline statements \newline \} else if ( condition ) \{ \newline statements \newline \} else \{ \newline statements \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Switch Statement}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{switch ( condition ) \{ \newline case value: \newline statements \newline break; \newline case value2: \newline statements \newline break; \newline default: \newline statements \newline break; \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{For loop}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{for ( initialize ; condition ; increment ) \{ \newline statements \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{While Loop}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{while ( condition ) \{ \newline statements \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Do-While Loop}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{do \{ \newline statements \newline \} while ( condition );} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{1D Arrays}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{element\_type{[}{]} variable\_name; \newline element\_type{[}{]} variable\_name = new element\_type {[} array\_size {]} ; \newline element\_type{[}{]} variable\_name = \{ value1, value2, value3, ... \}; \newline \newline element\_type name = variable\_name {[} index {]}; \newline variable\_name {[} index {]} = value; \newline \newline // example \newline \newline int{[}{]} arr = new int{[}10{]}; \newline double{[}{]} nums = \{22.1, 50, 34\}; \newline \newline int a = arr{[}0{]}; \newline arr{[}0{]} = 53; \newline \newline // iteration, full array, from start to end \newline for (int i = 0; i \textless{} arr.length; i++) \{ \newline int element = arr{[}i{]}; \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Methods}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{[}modifiers{]} return-type name ( parameters ) \{ \newline statements \newline \} \newline \newline // modifiers \newline {[} access-modifier {]} {[} static / abstract {]} {[} synchronized {]} {[} final {]} \newline \newline // examples \newline \newline public static void printName() \{ \newline statements \newline \} \newline \newline public void showNumbers(int a, int b) \{ \newline statements \newline \} \newline \newline public int sum(int a, int b) \{ \newline return a + b; \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Main}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{public static void main(String{[}{]} args) \{ \newline \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Class Structure}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{public class name \{ \newline \newline members \newline \newline constructors \newline \newline methods \newline \} \newline \newline public class name \{ \newline \newline private type var1; \newline private type var2; \newline \newline public name ( type var1, type var2) \{ \newline this.var1 = var1; \newline this.var2 = var2; \newline \} \newline \newline public return\_type method1 ( type param1, type param2 ) \{ \newline statements \newline \} \newline \newline public return\_type method2 ( params ) \{ \newline statements \newline \} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.204 cm} x{3.192 cm} x{2.204 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Primitive Data Types}} \tn % Row 0 \SetRowColor{LightBackground} byte & integers & 1 byte \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} short & integers & 2 bytes \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} int & integers & 4 bytes \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} long & integers & 8 bytes \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} float & decimals & 4 bytes \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} double & decimals & 8 bytes \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} char & characters & 2 bytes \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} boolean & boolean & 1 bytes \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.52 cm} x{4.48 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Arithmetic Operators}} \tn % Row 0 \SetRowColor{LightBackground} num1 + num2 & addition \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} num1 - num2 & subtraction \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} num1 * num2 & multiplication \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} num1 / num2 & division \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} num1 \% num2 & modulus \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} num++ & post increment \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} num-{}- & post decrement \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} ++num & pre increment \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} -{}-num & pre decrement \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.052 cm} x{3.116 cm} x{2.432 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Assignment Operators}} \tn % Row 0 \SetRowColor{LightBackground} num1 = value & & assignment \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} num1 += num2 & num1 = num1 + num2 & addition \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} num1 -= num2 & num1 = num1 - num2 & subtraction \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} num1 *= num2 & num1 = num1 * num2 & \seqsplit{multiplication} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} num1 /= num2 & num1 = num1 / num2 & division \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} num1 \%= num2 & num1 = num1 \% num2 & modulus \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.64 cm} x{5.36 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Comparison Operators}} \tn % Row 0 \SetRowColor{LightBackground} num1 == num2 & Equal To \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} num1 != num2 & Not Equal \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} num1 \textgreater{} num2 & Greater Than \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} num1 \textless{} num2 & Less Than \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} num1 \textgreater{}= num2 & Greater Than or Equal to \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} num1 \textless{}= num2 & Less Than or Equal to \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{5.2 cm} x{2.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Logical Operators}} \tn % Row 0 \SetRowColor{LightBackground} boolean1 \&\& boolean2 & Logical AND \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} boolean1 || boolean2 & Logical OR \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} ! boolean1 & Logical NOT \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.12 cm} x{4.88 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Binary Operators}} \tn % Row 0 \SetRowColor{LightBackground} num1 | num2 & Bitwise OR \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} num1 \& num2 & Bitwise AND \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} num1 \textasciicircum{} num2 & Bitwise XOR \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \textasciitilde{}num1 & Bitwise Complement \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} num1 \textgreater{}\textgreater{} num2 & Right Shift \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} num1 \textless{}\textless{} num2 & Left Shift \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} num1 \textgreater{}\textgreater{}\textgreater{} num2 & Unsigned Right Shift \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Type Conversion}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{// type casting \newline double val = 25.2; \newline int a = (int) val; // will be 25 \newline \newline // to string conversion \newline int number = 24; \newline String str = String.valueOf(number); \newline // or with string concat: "hello: " + number \newline \newline // string to int \newline String str = "25"; \newline int val = Integer.parseInt(str); \newline \newline // string to double \newline String str = "25.5"; \newline double val = Double.parseDouble(str);} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Literals}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{// integers \newline int num1 = 34; // base 10 (decimal) \newline int num2 = 042; // base 8 (octal) \newline int num3 = 0x22; // base 16 (hexadecimal) \newline int num4 = 0b00100010; // base 2 (binary) \newline long value = 2211153122345L; \newline \newline // decimals \newline float value = 155.4f; \newline double value = 155.4; \newline double value = 1.554e2; // exponent form \newline \newline // char, String \newline char a = 'A'; \newline char a = '\textbackslash{}u0021'; \newline char a = 67; \newline String b = "Hello World";} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Access Modifiers}} \tn % Row 0 \SetRowColor{LightBackground} public & Any code \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} private & Only code in the same class \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} protected & Only code in the same class, inheriting class or the same package \tn % Row Count 7 (+ 4) % Row 3 \SetRowColor{white} package-private (default, set no modifier) & Only code in the same package \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.64 cm} x{5.36 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Modifiers}} \tn % Row 0 \SetRowColor{LightBackground} final & Cannot be overriden or extended \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} static & Belongs to the class, rather than an instance \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} abstract (on method) & Declares the method as abstract, requiring no body \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} abstract (on class) & Declares the class as abstract, can contain abstract methods \tn % Row Count 9 (+ 3) % Row 4 \SetRowColor{LightBackground} synchronized & Holds monitor on class instance during method execution \tn % Row Count 12 (+ 3) % Row 5 \SetRowColor{white} transient & Attributes and methods are skipped when serializing the object containing them (via java object serialization) \tn % Row Count 17 (+ 5) % Row 6 \SetRowColor{LightBackground} volatile & The value of the attribute is not cached on CPU \tn % Row Count 19 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Math Methods}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{// basic \newline double pi = Math.PI; // pi \newline double val = Math.abs(-15); // 15, absolute value \newline double val = Math.signum(-15); // -1, sign (-1, 0, 1) \newline double val = Math.max(12, 13); // 13, max of 2 numbers \newline double val = Math.min(12, 13); // 12, min of 2 numbers \newline double val = Math.sqrt(16); // square root of number \newline double val = Math.pow(2, 4); // 2 to the power of 4 \newline \newline // round \newline double val = Math.ceil(15.2); // 16, round up \newline double val = Math.floor(15.2); // 15, round down \newline double val = Math.round(15.2); // 15, round to the closest \newline \newline // trigo \newline double degrees = Math.toDegrees(Math.PI); // radians to degrees \newline double radians = Math.toRadians(180); // degrees to radians \newline double val = Math.sin(radians); // sine func \newline double val = Math.cos(radians); // cosine func \newline double val = Math.tan(radians); // tangent func \newline double radians = Math.asin(value); // arc sine func \newline double radians = Math.acos(value); // arc cosine func \newline double radians = Math.atan(value); // arc tangent func} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Method Invocation}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{method\_name(); \newline method\_name( parameters ); \newline return\_type name = method\_name( parameters ); \newline \newline printName(); \newline int sum = sumNumbers(11, 90);} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Objects}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{// creation \newline Class\_Name var\_name; \newline Class\_Name var\_name = new Class\_Name(); \newline Class\_Name var\_name = new Class\_Name( parameters ); \newline \newline Person person; \newline Person person = new Person("Barak Obama", 25); \newline \newline // access \newline type name = var\_name.attribute; \newline var\_name.attribute = value; \newline \newline int a = person.age; \newline person.age = 55; \newline \newline // method invocation \newline var\_name.method\_name(); \newline var\_name.method\_name( parameters ); \newline return\_type name = var\_name.method\_name( parameters ); \newline \newline String name = person.getName(); \newline person.walkDistance(5);} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}