<p>Global variables is where you don't declare a variable inside a method. This is generally not a recommended practice. It is recommended to declare variables inside methods so that it is easier to reuse code.</p>
<pre><codeclass="language-java">public class mainDriver {
public static int globalVariable = 5; // I am a global variable
public static void main(String[] args) {
int localVariable = 4; // I am a local variable
}
}</code></pre>
<h2>String Formatting</h2>
<p>You can format strings in java by using the <code>printf</code> method in System.out.</p>
<p>Format strings work by using placeholders starting with <code>%</code> to specify where to place the value of a variable.</p>
System.out.printf("The tax is %.2f"); //prints "The tax is 0.46"</code></pre>
<h2>Floating point precision</h2>
<p>Due to how computers store non-integers, math can be non-precise after some mathematical operations. It is therefore advantageous to do operations on integers to the level of precision you want.</p>
<p>For example, instead of working in dollars, work in pennies since it's the smallest division we care about.</p>
<h3>ArrayList</h3>
<p>Standard arrays are static, meaning they have no ability to grow. Instead of doing the operations we described last class, in order to add something to an array. We can use something called an <code>ArrayList</code> instead.</p>
<p>The methods in the <code>ArrayList</code> library are useful abstractions to make the life of a programmer easier.</p>
<p>ArrayLists can also hold only one type. The type cannot be a primitive like a standard array. Instead it must be a class representing the desired type.</p>
<p>int -> Integer</p>
<p>double -> Double</p>
<p>char -> Character</p>
<p>float -> String</p>
<p>To declare and initialize an <code>ArrayList</code></p>