Write a program to check your own ip address...

import java.net.*;

class CheckIp
{
       public static void main(String args[])
      {
       try
       {
         InetAddress address=InetAddress.getLocalHost();
         System.out.println(address);
        }
     catch(UnknownHostException e)
   {
  System.out.println("could not find yahoo .com");
}
}
}

Write a program to comarision of two string.

class stringmethod
  {
    public static void main(String[] args)
      {
        String string1 = "Hi";
        String string2 = new String("Hello");
        if (string1 == string2)
           {
            System.out.println("The strings are equal.");
            }
        else
               {
                System.out.println("The strings are unequal.");
                }
        }
}               


Output of the program:-


The strings are unequal

Write a program to print a Stact Trace Message.

public class PrintStack
{
           public static void main (String args[])
              {
               String str = "Exception" ;
               int len=0;
           try
              {
             StringBuffer sbuf = new StringBuffer(str);
            len = str.length() ;
           for(int ct=len;ct>=0;ct--)
            {
          System.out.print(sbuf.charAt(ct));
           }
       }
       catch(Exception e)
      {
      e.printStackTrace();
       }
     }
   }



OUTPUT OF THE PROGRAM:-


java.lang.StringIndexOutOfBoundsException: String index out of range: 9
at java.lang.StringBuffer.charAt(Unknown Source)
at PrintStack.main(PrintStack.java:13)