/**
 * 
 */
package comments;

import utils.Foo;


/**
 * Demonstrate the memory misuse problem
 * 
 */
public class MemoryMisuse
{

	public static void main(String[] args)
	{
		foo();
		foo2();
		foo3();
		foo4();
		foo5(null, getFoo(), "Hello");
		foo6();

	}
	// Case 1:
	public static void foo() {
		int[][] arr = new int[100][100];

		for (int j = 0; j < arr.length; j++) {
			for (int j2 = 0; j2 < arr.length; j2++) {
				arr[j][j2] = j + j2;
			}
		}
	}

	// Case 2:
	public static void foo2()
	{
		String s = new String("go");
		Foo foo = new Foo();
		foo.foo();
		System.out.println(s);
	}

	// Case 3
	public static void foo3()
	{
		String s = getString();

		System.out.println(s);
	}

	// Case 4:
	public static void foo4()
	{
		String s = getString();
		String t = "s" + getString();
		Foo foo = getFoo();
		System.out.println(s+t);
		foo.foo();
	}

	// Case 5
	public static void foo5(int[] w,Foo f,String s)
	{
		w = new int[10];
		f = getFoo();
		s = "me";
	}

	// Case 6:
	public static void foo6()
	{
		String s = "Hello";
		String t = s + "There";
		String w = t;
		int i = 0;
		System.out.println(w+i);
	}

	public static String getString()
	{
		return "HelloThere";
	}

	public static Foo getFoo()
	{
		return new Foo();
		
		  for (i = 0; i < BZ_N_OVERSHOOT; i++) {
		      block   [nblock+i] = 0;
		   }

	}

	
	
	
	
}
