Java program will compile but not run
<p>I was wondering if someone could help me with this.</p>

<p>I have defined my interface as:</p>

<pre><code>interface Model 
{
public String  toString();
public Model add (Model m);
}
</code></pre>

<p>There are 2 classes implementing the interface (ClassA and ClassB):</p>

<pre><code>class ClassA implements Model
{
private int val;

public ClassA(int x) 
{
    val = x;
}

public String toString() 
{
 return ""+ "value of object of class A is " + val;
}

public Model add (Model m) 
{
 if (m instanceof ClassA)
   return new ClassA(val + ( (ClassA) m).val);
 else
   return null;
}
}

class ClassB implements Model 
{

private String str;

public  ClassB(String s)
{
 str = s;
}

public String toString()
{
 return str;
 }

 public Model add (Model m) 
 {
 if (m instanceof ClassB)                      
 return new ClassB(str + ((ClassB) m).str); 
 else
 return null;
 }
 }
</code></pre>

<p>My main defines objects of ClassA and ClassB and calls their tostring() methods.</p>

<pre><code>public class Example {
public static void main (String args[]) {
 ClassA a = new ClassA(5);
 ClassB b= new ClassB("Hi");

 Model m = b;
 System.out.println(m.toString());

 ClassA a1 = new ClassA(7);

 m = a.add(a1);

 System.out.println(m);
}
}
</code></pre>

<p>When I try to build this file it compiles fine but, upon trying to run the application I get an error message:</p>

<p>"Usage: java [-options] class [args...]
(to execute a class)
or  java [-options] -jar jarfile [args...]
(to execute a jar file).....etc...etc"</p>

<p>Can anyone help me with this? It's probably something simple. I'm a beginner Java student.</p>
