mirror of
https://github.com/Brandon-Rozek/website.git
synced 2024-12-01 14:10:49 -05:00
114 lines
3.9 KiB
HTML
114 lines
3.9 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="author" content="Fredrik Danielsson, http://lostkeys.se">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="robots" content="noindex" />
|
|
<title>Brandon Rozek</title>
|
|
<link rel="stylesheet" href="themes/bitsandpieces/styles/main.css" type="text/css" />
|
|
<link rel="stylesheet" href="themes/bitsandpieces/styles/highlightjs-github.css" type="text/css" />
|
|
</head>
|
|
<body>
|
|
|
|
<aside class="main-nav">
|
|
<nav>
|
|
<ul>
|
|
<li class="menuitem ">
|
|
<a href="index.html%3Findex.html" data-shortcut="">
|
|
Home
|
|
</a>
|
|
</li>
|
|
<li class="menuitem ">
|
|
<a href="index.html%3Fcourses.html" data-shortcut="">
|
|
Courses
|
|
</a>
|
|
</li>
|
|
<li class="menuitem ">
|
|
<a href="index.html%3Flabaide.html" data-shortcut="">
|
|
Lab Aide
|
|
</a>
|
|
</li>
|
|
<li class="menuitem ">
|
|
<a href="index.html%3Fpresentations.html" data-shortcut="">
|
|
Presentations
|
|
</a>
|
|
</li>
|
|
<li class="menuitem ">
|
|
<a href="index.html%3Fresearch.html" data-shortcut="">
|
|
Research
|
|
</a>
|
|
</li>
|
|
<li class="menuitem ">
|
|
<a href="index.html%3Ftranscript.html" data-shortcut="">
|
|
Transcript
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
</aside>
|
|
<main class="main-content">
|
|
<article class="article">
|
|
<h1>Lecture for March 29th</h1>
|
|
<h2>Enumerated Types</h2>
|
|
<p>These represent a fixed set of constants and include all possible values within them.</p>
|
|
<p>Let's look at coins. On a daily basis in the US, we use the following coins:</p>
|
|
<ul>
|
|
<li>Penny</li>
|
|
<li>Nickel</li>
|
|
<li>Dime</li>
|
|
<li>Quarter</li>
|
|
</ul>
|
|
<p>Other examples include the days of the week, clothes sizes, etc.</p>
|
|
<h2>Enum Syntax</h2>
|
|
<p>Let's define an <code>enum</code> type</p>
|
|
<pre><code class="language-java">public enum Coin { PENNY, NICKEL, DIME, QUARTER}</code></pre>
|
|
<p>Now declare and initialize a variable</p>
|
|
<pre><code class="language-java">Coin myCoin = Coin.PENNY</code></pre>
|
|
<h2>Arrays vs ArrayList</h2>
|
|
<p>Arrays require you to say upfront, how many slots you need. ArrayLists are more flexible since you can change the length of the array during Runtime. </p>
|
|
<p>Arrays can store objects and primitives such as <code>int</code>, <code>char</code>, <code>boolean</code>, etc.</p>
|
|
<p>ArrayLists can only store objects.</p>
|
|
<h3>How to declare an ArrayList</h3>
|
|
<pre><code class="language-java">ArrayList<objectType> list = new ArrayList<objectType>();</code></pre>
|
|
<h3>Differences between getting the length of the array</h3>
|
|
<p><strong>Array</strong></p>
|
|
<pre><code class="language-java">int length = array.length;</code></pre>
|
|
<p><strong>ArrayList</strong></p>
|
|
<pre><code class="language-java">int length = array.size();</code></pre>
|
|
<h2>For Each Loop</h2>
|
|
<p>This is a special loop in where you tell it to go through all the elements of the array, without specifying an index.</p>
|
|
<pre><code class="language-java">for (String b : buildings) {
|
|
System.out.print(b);
|
|
}</code></pre>
|
|
</article>
|
|
</main>
|
|
|
|
<script src="themes/bitsandpieces/scripts/highlight.js"></script>
|
|
<script src="themes/bitsandpieces/scripts/mousetrap.min.js"></script>
|
|
<script type="text/x-mathjax-config">
|
|
MathJax.Hub.Config({
|
|
tex2jax: {
|
|
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
|
|
processEscapes: true
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<script type="text/javascript"
|
|
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
|
|
</script>
|
|
<script>
|
|
hljs.initHighlightingOnLoad();
|
|
|
|
document.querySelectorAll('.menuitem a').forEach(function(el) {
|
|
if (el.getAttribute('data-shortcut').length > 0) {
|
|
Mousetrap.bind(el.getAttribute('data-shortcut'), function() {
|
|
location.assign(el.getAttribute('href'));
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|