جاوا-چگونه کلاس Exception مورد نظر خود را پیاده سازی کنیم؟

در این sample نشان داده شده است که چگونه می توان کلاس Exception مورد نظر خود را نوشت و آن را Throw کرد: 

public class MyException extends Exception
{
  public String toString(String str1)
  {
   return str1;
  }
}
public class Test
{
 public static void meth1(int a, int b) throws MyException
  {
   if (a<b) throw new MyException();
  }
 public static void main(String arg[])
  {
   try
    {
      Test.meth1(1,2);   
    }catch(MyException e)
    {
      System.out.println(e.toString("It is my Exception Test"));
      e.printStackTrace();
    }
  }
}

چند نکته در جاوا

1.       Java removed pointers and it is a reason for security in java.

2.       For transferring HTML files, the HTTP protocol was discovered.

3.       Java has compiler and interpreter.

4.       Java compiler creates byte code file.

5.       Byte code is a language for JVM.

6.       Byte code will be interpreted to the appropriate language of processor by interpreter.

7.       Applets do not have main method, they have init(), start() and paint() methods.