Files
uni/third/semester1/CT326_Programming_III/notes/_minted-CT326-Notes/2F86992A901A33F001A3A366DADC21E6CFCD10B6E967F145489C3C2B47048B4F.pygtex
2023-12-07 02:17:27 +00:00

15 lines
1.2 KiB
Plaintext

\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}]
\PYG{n}{ArrayList}\PYG{o}{\PYGZlt{}}\PYG{n}{Integer}\PYG{o}{\PYGZgt{}}\PYG{+w}{ }\PYG{n}{list}\PYG{+w}{ }\PYG{o}{=}\PYG{+w}{ }\PYG{k}{new}\PYG{+w}{ }\PYG{n}{ArrayList}\PYG{o}{\PYGZlt{}}\PYG{n}{Integer}\PYG{o}{\PYGZgt{}}\PYG{p}{();}
\PYG{c+c1}{// looping though an ArrayList using the Iterator class}
\PYG{k}{for}\PYG{+w}{ }\PYG{p}{(}\PYG{n}{Iterator}\PYG{+w}{ }\PYG{n}{i}\PYG{+w}{ }\PYG{o}{=}\PYG{+w}{ }\PYG{n}{list}\PYG{p}{.}\PYG{n+na}{iterator}\PYG{p}{();}\PYG{+w}{ }\PYG{n}{i}\PYG{p}{.}\PYG{n+na}{hasNext}\PYG{p}{();)}\PYG{+w}{ }\PYG{p}{\PYGZob{}}
\PYG{+w}{ }\PYG{n}{Integer}\PYG{+w}{ }\PYG{n}{value}\PYG{+w}{ }\PYG{o}{=}\PYG{+w}{ }\PYG{p}{(}\PYG{n}{Integer}\PYG{p}{)}\PYG{+w}{ }\PYG{n}{i}\PYG{p}{.}\PYG{n+na}{next}\PYG{p}{();}
\PYG{+w}{ }\PYG{c+c1}{// do some stuff}
\PYG{p}{\PYGZcb{}}
\PYG{c+c1}{// looping though an ArrayList using a For-Each loop}
\PYG{k}{for}\PYG{+w}{ }\PYG{p}{(}\PYG{n}{Integer}\PYG{+w}{ }\PYG{n}{i}\PYG{+w}{ }\PYG{p}{:}\PYG{+w}{ }\PYG{n}{list}\PYG{p}{)}\PYG{+w}{ }\PYG{p}{\PYGZob{}}
\PYG{+w}{ }\PYG{c+c1}{// do some stuff}
\PYG{p}{\PYGZcb{}}
\end{Verbatim}