Java - Memory Implementation
<pre><code>class Memory{
    private int[] memoryArray;
    private int size;
    public Memory(int n)
    {size = n;
        memoryArray = new int[n];
        for(int i=0;i&lt;n;i++)
            memoryArray[i] = -1;
    }
    public void write (int loc,int val)
    {if (loc &gt;=0 &amp;&amp; loc &lt; size)
            memoryArray[loc] = val;
        else
            System.out.println("index out of range");
    }
    public int read (int loc)
    {return memoryArray[loc];
    }
</code></pre>

<p>}</p>

<p>Here is my program to test it...</p>

<pre><code>class Test{
    public static void main(String[] args)
    {
        Memory mymem = new Memory(100);
        mymem.write(98 , 4);
        int x;
        x = mymem.read(98);
        System.out.println(mymem);
        mymem.dump();
        for(int i=0;i&lt;size;i++)
            if(i%10==0)
                System.out.println(memoryArray[i]);
                                   else
                                       System.out.println(memoryArray[i]);
                                   }
    }
</code></pre>

<p>So when I type in java Memory to run it I get an error saying "Exception in thread "main" java.lang.NoSuchMethodError:main and when I run java Test it outputs Memory@9931f5....How can I fix this?</p>
