|
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 } } } |
|
See also
Do you have a Java Problem?
Java Books
Return to : Java Programming Hints and Tips All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
|