Class Time And Class Try To Parse String

Class Time

class  time

{

        public static void main(String[] args) 

        {

                int minutes= 197;

                System.out.println("197 minutes becomes 3 hours and 17 minutes");

        }

}

Class Try to parse string

public class TryToParseString {

 public static void main(String[] args) {

   int i;

   String str = "a";   // change this to any string you want

   try {

     i = Integer.parseInt ( str ) ;    // get the integer

     System.out.println(i);            // print out i

   } catch  ( NullPointerException npe )   {

     System.out.println(str + " is not defined");

                                       // if str is not defined

   }

   catch  ( NumberFormatException nfe )   {

     System.out.println(str + " is not a number");

                                       // if str is not a number

   }

 }

}

Java Tips

See also
Program to test the Time class

Do you have a Java Problem?
Ask It in The Java Forum

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.