Posts

Showing posts with the label java

Java code for opening the default email application

import java.awt.*; import java.io.IOException; import java.net.URI; public class sendmail {     public static void main(String[] args)      {         Desktop d;         try         {         if (Desktop.isDesktopSupported() && (d = Desktop.getDesktop()).isSupported(Desktop.Action.MAIL))          {             URI msg = new URI("mailto:user@anything.com?subject=sending%20email");             d.mail(msg);          }             else             {                     throw new RuntimeException("doesn't support this");              }         }         catch(Exception e)      ...

Java program to get the first letter of a string

Program import java.io .*; import java.lang .*; class test { public static void main(String[] args) { String a=”helloo”; char first=a.charAt(0); System.out.println(first ); } } Output   h