Dark Horse programmer-common objects

Source: Internet
Author: User

Package COM. yang. ex18; import Java. util. properties;/** system: the methods and properties in the class are static. * Out: standard output. The default value is console * In: standard input, by default, the keyboard ** describes system information * obtains system property information: Properties getproperties () **/public class demo {public static void main (string [] ARGs) {// todo auto-generated method stub properties = system. getproperties (); // because properties is a subclass of hashtable, it is also a subclass object of the map set. // You can use the map method to retrieve the elements in the set. All the elements stored in the set are strings without generic definitions. // you can customize some special information system in the system. setproperty ("key", "value"); // gets the specified property information system. getproperty ("OS. name "," value "); // when JVM is started, some attribute information is dynamically loaded string v = system. getproperty ("hah1"); system. out. println (V); For (Object object: properties. keyset () {string value = (string) properties. get (object); system. out. println (value) ;}} package COM. yang. ex18; import Java. text. simpledatef Ormat; import Java. util. *; public class datedemo {public static void main (string ARGs []) {date = new date (); system. out. println (date); simpledateformat sdateformat = new simpledateformat ("mm DD, yyyy hh: mm e "); // call the format method to format the specified date object string tistring = sdateformat. format (date); system. out. println (tistring) ;}} package COM. yang. ex18; import Java. text. simpledateformat; import Java. util. calendar; impor T Java. util. date; public class calendardemo {public static void main (string [] ARGs) {// todo auto-generated method stub date = new date (); Calendar calendar = calendar. getinstance (); system. out. println (calendar); system. out. println (calendar. get (calendar. year); system. out. println (calendar. get (calendar. month); system. out. println (); // simpledateformat = new simpledateformat ("yyy Y "); // string yearstring = simpledateformat. format (date); // system. out. println (yearstring); // }}} package COM. yang. ex18; import Java. util. random; public class mathdemo {public static void main (string [] ARGs) {// todo auto-generated method stub double D = math. ceil (12.34); // Ceil returns the smallest integer system greater than the specified data. out. println (d); long l = math. round (12.24); // round to random r = new random (); system. out. println (l); For (int I = 0; I <10; I ++) {double d1 = (INT) (math. random () * 10 + 1); int D2 = R. nextint (10); system. out. println (D2) ;}} package COM. yang. ex18;/** runtime object: * The constructor is not provided in this class. It indicates that the new object is not allowed. * You will directly think that the methods in this class are static. * You will find that there are non-static methods in this class. * This class will certainly provide methods to obtain the class objects, the method is static, and the returned value * type is the class type. ** This method is: static runtime getruntime (); * This feature shows that this class uses the single-column design mode to complete **/public class runtimedemo {public static void main (string [] ARGs) throws exception {// todo auto-generated method stubruntime runtime = runtime. getruntime (); process process=runtime.exe C ("notepad.exe demo. java "); // process. destroy ();}}

See http://edu.csdn.net/heima for details

Dark Horse programmer-common objects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.