"Dead Knock Jeestie Source" type back three points (String ...) The difference between the array (string[])

Source: Internet
Author: User

Type three points (String ...), starting with Java 5 , the Java language supports a new notation for method parameters, called variable-length parameter lists , whose syntax is a type followed by ..., Indicates that the parameter accepted here is 0 to more objects of type object, or is a object[]. For example, we have a method called Test (string...strings), then you can also write the method test (), but you cannot write test (string[] strings), this will be a compilation error, the system prompts for duplicate methods.

In use, for Test (string...strings), you can directly use test () to call, marked no parameters, you can use to test ("AAA"), you can also use test (new string[]{"AAA", "BBB"}).

If you have both the test (string...strings) function and the test () function, we will use the test () function first when we call Test (). Only if there is no test () function, we call Test (), the program will walk Test (string...strings).

 Public classTest003 {PrivateTest003 () {test (); Test (Newstring[]{"AAA", "BBB"}); Test ("CCC"); }                Private voidTest () {System.out.println ("Test"); }                Private voidTest (string...strings) { for(String str:strings) {System.out.print (str+ ", ");        } System.out.println (); }                /*private void Test (string[] strings) {System.out.println (3); }*/                 Public Static voidMain (string[] args) {NewTest003 (); }        }  

The source code for the properties file is loaded in the Jeestie framework:

/*** Copyright (c) 2005-2011 springside.org.cn * * $Id: Propertiesloader.java 1690 2012-02-22 13:42:00z Calvinxiu $ */ Packagecom.thinkgem.jeesite.common.utils;Importjava.io.IOException;ImportJava.io.InputStream;ImportJava.util.Map;Importjava.util.NoSuchElementException;Importjava.util.Properties;Importorg.apache.commons.io.IOUtils;ImportOrg.slf4j.Logger;Importorg.slf4j.LoggerFactory;ImportOrg.springframework.core.io.DefaultResourceLoader;ImportOrg.springframework.core.io.Resource;ImportOrg.springframework.core.io.ResourceLoader;ImportCom.google.common.collect.Maps;/*** Properties file Loading tool class. You can load multiple properties files, and the values in the last loaded file will overwrite the previous value, but the system property takes precedence. *@authorCalvin *@version2013-05-15*/ Public classPropertiesloader {Private StaticLogger Logger = Loggerfactory.getlogger (propertiesloader.class); Private StaticResourceloader Resourceloader =NewDefaultresourceloader (); Private FinalProperties Properties;  PublicPropertiesloader (String ... resourcespaths) {Properties=loadProperties (resourcespaths); }     PublicProperties getProperties () {returnproperties; }    /*** The property is removed, but the property in system takes precedence and the return empty string is not available. */    Privatestring GetValue (String key) {string Systemproperty=System.getproperty (key); if(Systemproperty! =NULL) {            returnSystemproperty; }        if(Properties.containskey (key)) {returnProperties.getproperty (key); }        return""; }    /*** Remove the property of type string, but the property of system takes precedence, if all is null throws an exception. */     Publicstring GetProperty (String key) {String value=GetValue (key); if(Value = =NULL) {            Throw Newnosuchelementexception (); }        returnvalue; }    /*** Remove the property of type string, but the property of system takes precedence. Returns the default value if both are null. */     Publicstring GetProperty (String key, String defaultvalue) {String value=GetValue (key); returnValue! =NULL?Value:defaultvalue; }    /*** Take out the property of the integer type, but the system property takes precedence. Throws an exception if both are null or the content is wrong. */     PublicInteger Getinteger (String key) {String value=GetValue (key); if(Value = =NULL) {            Throw Newnosuchelementexception (); }        returninteger.valueof (value); }    /*** Take out the property of the integer type, but the system property takes precedence. Returns the default value if both are null and throws an exception if the content is wrong*/     Publicinteger Getinteger (string key, Integer defaultvalue) {String value=GetValue (key); returnValue! =NULL?integer.valueof (value): defaultvalue; }    /*** The property of the double type is removed, but the property of the system takes precedence. Throws an exception if both are null or content errors. */     PublicDouble getdouble (String key) {String value=GetValue (key); if(Value = =NULL) {            Throw Newnosuchelementexception (); }        returndouble.valueof (value); }    /*** Remove the property of the double type, but the system property takes precedence. Returns the default value if both are null and throws an exception if the content is wrong*/     PublicDouble getdouble (string key, Integer defaultvalue) {String value=GetValue (key); returnValue! =NULL?double.valueof (value): defaultvalue; }    /*** Remove the Boolean property, but the system property takes precedence. If both null throws an exception, false is returned if the content is not true/false. */     PublicBoolean Getboolean (String key) {String value=GetValue (key); if(Value = =NULL) {            Throw Newnosuchelementexception (); }        returnboolean.valueof (value); }    /*** Remove the Boolean property, but the system property takes precedence. Returns the default value if it is null, or False if the content is not true/false. */     PublicBoolean Getboolean (String key,BooleanDefaultValue) {String value=GetValue (key); returnValue! =NULL?boolean.valueof (value): defaultvalue; }    /*** Load multiple files, file paths using spring resource format. */    PrivateProperties LoadProperties (String ... resourcespaths) {Properties Props=NewProperties ();  for(String location:resourcespaths) {//logger.debug ("Loading Properties file from:" + location);InputStream is=NULL; Try{Resource Resource=Resourceloader.getresource (location); is=Resource.getinputstream ();            Props.load (IS); } Catch(IOException ex) {Logger.info ("Could not load properties from path:" + location + "," +ex.getmessage ()); } finally{ioutils.closequietly (IS); }        }        returnprops; }                     Public Static voidMain (string[] args) {Map<string, string> map =Maps.newhashmap (); Propertiesloader Loader=NewPropertiesloader ("Jeesite.properties"); String Key= "AdminPath"; String value=Map.get (key); if(Value = =NULL) {Value=Loader.getproperty (key); Map.put (key, Value!=NULL?Value:StringUtils.EMPTY);    } System.out.println (value); }}
View Code

"Dead Knock Jeestie Source" type back three points (String ...) The difference between the array (string[])

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.