\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{aloha} \pdfinfo{ /Title (basic-java-statements-ja.pdf) /Creator (Cheatography) /Author (aloha) /Subject (Basic Java Statements (ja) 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}{4369A3} \definecolor{LightBackground}{HTML}{F3F5F9} \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{Basic Java Statements (ja) Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{aloha} via \textcolor{DarkBackground}{\uline{cheatography.com/76138/cs/18832/}}} \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}aloha \\ \uline{cheatography.com/aloha} \\ \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 21st February, 2019.\\ 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} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{if statement}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{/{\emph{ \newline }} \seqsplit{評価結果を真偽値で返す式のみ条件式として記述可能} \newline {\emph{ \seqsplit{複数のif文を入れ子構造とすることが可能} \newline }}/ \newline \newline {\bf{if (}} {\emph{条件式A}} {\bf{) \{}} \newline {\bf{if (}} {\emph{条件式B}} {\bf{) \{}} \newline {\emph{処理①}} {\bf{;}} \newline {\bf{\} else \{}} \newline {\bf{if (}} {\emph{条件式C}} {\bf{) \{}} \newline {\emph{処理②}} {\bf{;}} \newline {\bf{\}}} \newline {\emph{処理③}} {\bf{;}} \newline {\bf{\}}} \newline {\bf{\} else if (}} {\emph{条件式D}} {\bf{) \{}} \newline {\emph{処理④}} {\bf{;}} \newline {\bf{\} else \{}} \newline {\emph{処理⑤}} {\bf{;}} \newline {\bf{\}}}} \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}{if (sample)}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{// \seqsplit{ステータスコードの判断結果がCONTINUEDの場合} \newline {\bf{if (cmnUtils.judgeStatus(statusCode)}} \newline {\bf{== EnumCode.CONTINUED) \{}} \newline // \seqsplit{anyEntity配下に子が紐付いていない場合} \newline {\bf{if \seqsplit{(anyEntity.hasNotChildsConnected())} \{}} \newline {\bf{anyEntity.getChilds();}} \newline {\bf{\}}} \newline // \seqsplit{anyEntity配下の子を昇順で並び替える} \newline {\bf{anyEntity.sortChilds(EnumAttr.ASC);}} \newline // \seqsplit{ステータスコードの判断結果がskippedの場合} \newline {\bf{\} else if (cmnUtils.judgeStatus(statusCode)}} \newline {\bf{== EnumCode.SKIPPED) \{}} \newline {\bf{return;}} \newline // \seqsplit{ステータスコードの判断結果が上記に該当しない場合} \newline {\bf{\} else \{}} \newline {\bf{throw new HogeException("未定義のステータス");}} \newline {\bf{\}}}} \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}{for statement}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{/{\emph{ \newline }} \seqsplit{【基本for文】:指定回数分の繰り返し} \newline {\emph{ \seqsplit{①ブロック内で有効な一時変数の宣言&初期化を行う。} \newline }} -\textgreater{} \seqsplit{for文の最初に一度だけ実行される。} \newline {\emph{ -\textgreater{} \seqsplit{変数宣言部のみfor宣言前に記述可能。(非推奨)} \newline }} \seqsplit{②条件式の評価がtrueの間、処理が繰り返される。} \newline {\emph{ -\textgreater{} \seqsplit{ブロック内の処理が実行される前に評価される。} \newline }} \seqsplit{③ブロック内の処理が終了した後に評価される。} \newline {\emph{ -\textgreater{} \seqsplit{どんな式でも良いが、通常は①の変数を更新する。} \newline }} \newline {\emph{ \seqsplit{※①〜③いずれの要素も省略可(セミコロンは必須!)} \newline }}/ \newline {\bf{for ( }}{\emph{①初期化}} {\bf{;}} {\emph{②条件式}} {\bf{;}} {\emph{③更新用{\bf{}} ) \{}} \newline {\emph{処理}} {\bf{;}} \newline {\bf{\}}} \newline \newline /{\emph{ \newline }} 【拡張for文 (別称: for-each文)】: \newline {\emph{ \seqsplit{対象の全要素を一つずつ取得しながら繰り返し} \newline }} \seqsplit{①forブロック内で使用可能な一時変数の宣言を行う。} \newline {\emph{ -\textgreater{} \seqsplit{対象から取得した要素が一時的に格納される。} \newline }} -\textgreater{} \seqsplit{繰り返す度に順次要素が格納されていく。} \newline {\emph{ ②配列、及び Iterable \seqsplit{を実装したオブジェクト} \newline }} -\textgreater{} Iterable \seqsplit{はインタフェース。} \newline {\emph{/ \newline {\bf{for ( }}}}① 型 一時変数名{\emph{ {\bf{:}} }}②Iterableなやつ{\bf{{\emph{ ) \{}} \newline }}処理* {\bf{;}} \newline {\bf{\}}}} \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}{for (sample)}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{int{[}{]} array = \{3, 5, 6, 2, 9, 1\};}} \newline \newline // 挿入ソート \newline {\bf{for(int i=1; i \textless{} array.length; i++) \{}} \newline {\bf{for(int j=i; j\textgreater{}=1 \&\& array{[}j{]} \textless{} array{[}j-1{]}; j-{}-) \{}} \newline {\bf{int tmp = array{[}j{]};}} \newline {\bf{array{[}j{]} = array{[}j-1{]};}} \newline {\bf{array{[}j-1{]} = tmp;}} \newline {\bf{\}}} \newline {\bf{\}}}} \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}{for-each (sample)}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{String{[}{]} strArray = \{"", "安全", " ", null, "対策"\};}} \newline {\bf{JpStrings jp = new JpStrings();}} \newline \newline // \seqsplit{リスト要素を1つずつ取得しながら繰り返し} \newline {\bf{for (String str : strArray) \{}} \newline \newline // \seqsplit{文字列がnull、空文字、空白の場合} \newline {\bf{if (!cmnUtils.isEffectiveString(str)) \{}} \newline // \seqsplit{次のstrArray要素の処理へ進む} \newline {\bf{continue;}} \newline {\bf{\}}} \newline // 文字列を取り込む \newline {\bf{jp.takeIntoBuffer(str);}} \newline {\bf{\}}} \newline // \seqsplit{縦書き形式で標準出力に出力する} \newline {\bf{cmnIO.sysoutFromBuffer(jp.transformVertical());;}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}