<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>爱周末 &#187; Java</title>
	<atom:link href="http://zhoumo123.cn/category/java/feed" rel="self" type="application/rss+xml" />
	<link>http://zhoumo123.cn</link>
	<description>知识分享，共同进步。zhoumo123.cn</description>
	<lastBuildDate>Thu, 07 Nov 2019 05:53:49 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.1</generator>
	<item>
		<title>String&#8230;类型后面三个点(String&#8230;)和数组(String[])的区别</title>
		<link>http://zhoumo123.cn/java/3644.html</link>
		<comments>http://zhoumo123.cn/java/3644.html#comments</comments>
		<pubDate>Thu, 09 Aug 2018 01:03:51 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3644</guid>
		<description><![CDATA[类型后面三个点(String…)，是从Java 5开始，Java语言对方法参数支持一种新写法，叫可变长度参数列表，其语法就是类型后跟…，表示此处接受的参数为0到多个Object类型的对象，或者是一个Object[]。 例如我们有一个方法叫做test(String…strings)，那么你还可以写方法test()，但你不能写test(String[] strings)，这样会出编译错误，系统提示出现重复的方法。 在使用的时候，对于test(String…strings)，你可以直接用test()去调用，标示没有参数，也可以用去test(“aaa”)，也可以用test(new String[]{“ ...  <a href="http://zhoumo123.cn/java/3644.html">  阅读全文 </a>]]></description>
				<content:encoded><![CDATA[<p>类型后面三个点(String…)，是从Java 5开始，Java语言对方法参数支持一种新写法，叫可变长度参数列表，其语法就是类型后跟…，表示此处接受的参数为0到多个Object类型的对象，或者是一个Object[]。 例如我们有一个方法叫做test(String…strings)，那么你还可以写方法test()，但你不能写test(String[] strings)，这样会出编译错误，系统提示出现重复的方法。</p>
<p>在使用的时候，对于test(String…strings)，你可以直接用test()去调用，标示没有参数，也可以用去test(“aaa”)，也可以用test(new String[]{“aaa”,”bbb”})。</p>
<p>另外如果既有test(String…strings)函数，又有test()函数，我们在调用test()时，会优先使用test()函数。只有当没有test()函数式，我们调用test()，程序才会走test(String…strings)。</p>
<pre class="brush: java; title: ; notranslate">

public class Test003 {

private Test003(){
test();
test(&quot;a&quot;,&quot;b&quot;);
test(new String[]{&quot;aaa&quot;,&quot;bbb&quot;});
test(&quot;ccc&quot;);
}

private void test(){
System.out.println(&quot;test&quot;);
}

private void test(String...strings){
for(String str:strings){
System.out.print(str + &quot;, &quot;);
}
System.out.println();
}
public static void main(String[] args) {
new Test003();
}

}

</pre>
<p>来源：https://blog.csdn.net/zhangdongnihao/article/details/74295696</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/java/3644.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>slf4j下载及LoggerFactory.getLogger说明</title>
		<link>http://zhoumo123.cn/java/3628.html</link>
		<comments>http://zhoumo123.cn/java/3628.html#comments</comments>
		<pubDate>Wed, 20 Dec 2017 03:46:40 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[slf4j]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3628</guid>
		<description><![CDATA[LoggerFactory.getLogger使用指定类初始化日志对象，在日志输出的时候，可以打印出日志信息所在类。如： private static final Logger logger = LoggerFactory.getLogger(Slf4jDemo.class); logger.debug(&#8220;日志信息&#8221;); 将会打印出: Slf4jDemo : 日志信息 slf4j下载 下载地址：https://www.slf4j.org/download.html &#160; &#160;]]></description>
				<content:encoded><![CDATA[<p>LoggerFactory.getLogger使用指定类初始化日志对象，在日志输出的时候，可以打印出日志信息所在类。如：<br />
<strong>private static final Logger logger = LoggerFactory.getLogger(Slf4jDemo.class);</strong><br />
logger.debug(&#8220;日志信息&#8221;);<br />
将会打印出: Slf4jDemo : 日志信息</p>
<p><strong>slf4j下载</strong></p>
<p>下载地址：https://www.slf4j.org/download.html</p>
<p>&nbsp;</p>
<p><a href="http://zhoumo123.cn/wp-content/uploads/2017/12/slf4j-download1.jpg"><img class="alignnone wp-image-3630 size-full" title="slf4j下载" src="http://zhoumo123.cn/wp-content/uploads/2017/12/slf4j-download1.jpg" alt="slf4j-download" width="576" height="515" /></a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/java/3628.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSON.parseObject(json字符串，对象.class)将str转对象 (JSONObject.parseObject)</title>
		<link>http://zhoumo123.cn/java/3626.html</link>
		<comments>http://zhoumo123.cn/java/3626.html#comments</comments>
		<pubDate>Wed, 20 Dec 2017 03:18:59 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JSON.parseObject]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3626</guid>
		<description><![CDATA[将JSON字符串转换成java中的POJO对象。在fastJson中已经有提供好的方法：JSON.parseObject(json字符串，对象.class);使用方式如下： 运行后结果如下： Name = james, age = 12 使用jar包：fastjson-1.1.36.jar包 parseObject(String str)的作用 JSON.parseObject（String str）是将str转化为相应的JSONObject对象，其中str是“键值对”形式的json字符串，转化为JSONObject对象之后就可以使用其内置的方法，进行各种处理了。 JSON.parseObje ...  <a href="http://zhoumo123.cn/java/3626.html">  阅读全文 </a>]]></description>
				<content:encoded><![CDATA[<p>将JSON字符串转换成java中的POJO对象。在fastJson中已经有提供好的方法：<strong>JSON.parseObject</strong>(json字符串，对象.class);使用方式如下：</p>
<pre class="brush: java; title: ; notranslate">
package json;

import com.alibaba.fastjson.JSON;

public class TestJson {

    String name;
    String age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public static void main(String[] args) {
        String jsonStr = &quot;{\&quot;name\&quot;:\&quot;james\&quot;, \&quot;age\&quot;:12}&quot;;
        TestJson test = JSON.parseObject(jsonStr, TestJson.class);
        System.out.printf(&quot;Name = %s, age = %s&quot;, test.getName(), test.getAge());
    }
}
</pre>
<p><strong>运行后结果如下：</strong></p>
<p>Name = james, age = 12<br />
使用jar包：fastjson-1.1.36.jar包</p>
<p><strong>parseObject(String str)的作用</strong><br />
JSON.parseObject（String str）是将str转化为相应的JSONObject对象，其中str是“键值对”形式的json字符串，转化为JSONObject对象之后就可以使用其内置的方法，进行各种处理了。</p>
<p><strong>JSON.parseObject(String str)与 JSONObject.parseObject(String str)的区别</strong><br />
根据源码显示：JSON是一个抽象类，JSON中有一个静态方法parseObject（String text），将text解析为一个JSONObject对象并返回；JSONObject是一个继承自JSON的类，当调用JSONObject.parseObject（result）时，会直接调用父类的parseObject（String text）。所以两者没什么区别，一个是用父类去调用父类自己的静态的parseObject（String text），一个是用子类去调用父类的静态parseObject（String text），两者调的是同一个方法。</p>
<p>参考：</p>
<p>https://segmentfault.com/q/1010000005733442</p>
<p>http://blog.csdn.net/dafeige8/article/details/73924034</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/java/3626.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>map遍历4种方式获取map的key与value</title>
		<link>http://zhoumo123.cn/java/3617.html</link>
		<comments>http://zhoumo123.cn/java/3617.html#comments</comments>
		<pubDate>Tue, 07 Nov 2017 11:35:43 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3617</guid>
		<description><![CDATA[map遍历的方式有多种，今天分享一下map遍历的4种方式，如何获取map的key与value。 方式1：通过Map.keySet遍历key和value 方式二：通过Map.entrySet使用iterator遍历key和value 方式三：推荐，尤其是容量大时 方式四：通过Map.values()遍历所有的value，但不能遍历key &#160; &#160; 来源：http://www.cnblogs.com/blest-future/p/4628871.html]]></description>
				<content:encoded><![CDATA[<p>map遍历的方式有多种，今天分享一下map遍历的4种方式，如何获取map的key与value。</p>
<pre class="brush: java; title: ; notranslate">
        Map&lt;Integer, String&gt; map = new HashMap&lt;Integer, String&gt;();
        map.put(1, &quot;a&quot;);
        map.put(2, &quot;b&quot;);
        map.put(3, &quot;ab&quot;);
        map.put(4, &quot;ab&quot;);
        map.put(4, &quot;ab&quot;);
        System.out.println(map.size());
        </pre>
<p><strong>方式1：通过Map.keySet遍历key和value</strong></p>
<pre class="brush: java; title: ; notranslate">
/*
* Set set = map.keySet(); //得到所有key的集合
*
* for (Integer in : set) { String str = map.get(in);
* System.out.println(in + &quot; &quot; + str); }
*/
System.out.println(&quot;通过Map.keySet遍历key和value：&quot;);
for (Integer in : map.keySet()) {
//map.keySet()返回的是所有key的值
String str = map.get(in);//得到每个key多对用value的值
System.out.println(in + &quot; &quot; + str);
}

</pre>
<p><strong>方式二：通过Map.entrySet使用iterator遍历key和value</strong></p>
<pre class="brush: java; title: ; notranslate">

System.out.println(&quot;通过Map.entrySet使用iterator遍历key和value：&quot;);
Iterator&lt;Map.Entry&lt;Integer, String&gt;&gt; it = map.entrySet().iterator();
while (it.hasNext()) {
    Map.Entry&lt;Integer, String&gt; entry = it.next();
    System.out.println(&quot;key= &quot; + entry.getKey() +
    &quot; and value= &quot; + entry.getValue());
}

</pre>
<p><strong>方式三：推荐，尤其是容量大时</strong></p>
<pre class="brush: java; title: ; notranslate">

System.out.println(&quot;第三种：通过Map.entrySet遍历key和value&quot;);
for (Map.Entry&lt;Integer, String&gt; entry : map.entrySet()) {
     //Map.entry&lt;Integer,String&gt; 映射项（键-值对）  
     //有几个方法：用上面的名字entry
    //entry.getKey() ;entry.getValue(); entry.setValue();
    //map.entrySet()  返回此映射中包含的映射关系的 Set视图。
    System.out.println(&quot;key= &quot; + entry.getKey() + &quot; and value= &quot;
                    + entry.getValue());
}
</pre>
<p><strong>方式四：通过Map.values()遍历所有的value，但不能遍历key</strong></p>
<pre class="brush: java; title: ; notranslate">
System.out.println(&quot;通过Map.values()遍历所有的value，但不能遍历key&quot;);
for (String v : map.values()) {
    System.out.println(&quot;value= &quot; + v);
}
</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://zhoumo123.cn/wp-content/uploads/2017/11/java-map1.png"><img class="alignnone wp-image-3621 size-full" title="map遍历4种方式获取map的key与value" src="http://zhoumo123.cn/wp-content/uploads/2017/11/java-map1.png" alt="map遍历4种方式获取map的key与value" width="631" height="321" /></a></p>
<p>来源：http://www.cnblogs.com/blest-future/p/4628871.html</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/java/3617.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Map.containsKey方法(判断Map集合对象中是否包含指定的键名)</title>
		<link>http://zhoumo123.cn/java/3614.html</link>
		<comments>http://zhoumo123.cn/java/3614.html#comments</comments>
		<pubDate>Thu, 26 Oct 2017 06:27:53 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[Map.containsKey]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3614</guid>
		<description><![CDATA[Map集合允许值对象为null，并且没有个数限制，所以当get()方法的返回值为null时，可能有两种情况，一种是在集合中没有该键对象，另一种是该键对象没有映射任何值对象，即值对象为null。因此，在Map集合中不应该利用get()方法来判断是否存在某个键，而应该利用containsKey()方法来判断。 该方法判断Map集合对象中是否包含指定的键名。如果Map集合中包含指定的键名，则返回true，否则返回false。 语法  containsKey(Object key)  &#160;]]></description>
				<content:encoded><![CDATA[<p>Map集合允许值对象为null，并且没有个数限制，所以当get()方法的返回值为null时，可能有两种情况，一种是在集合中没有该键对象，另一种是该键对象没有映射任何值对象，即值对象为null。因此，在Map集合中不应该利用get()方法来判断是否存在某个键，而应该利用<strong>containsKey()</strong>方法来判断。</p>
<p>该方法判断Map集合对象中是否包含指定的键名。如果Map集合中包含指定的键名，则返回true，否则返回false。</p>
<p><strong>语法  containsKey(Object key) </strong></p>
<pre class="brush: java; title: ; notranslate">

public static void main(String[] args) {

Map map = new HashMap();       //定义Map对象

map.put(&quot;apple&quot;, &quot;新鲜的苹果&quot;);      //向集合中添加对象

map.put(&quot;computer&quot;, &quot;配置优良的计算机&quot;);

map.put(&quot;book&quot;, &quot;堆积成山的图书&quot;);

map.put(&quot;time&quot;, new Date());

String key = &quot;book&quot;;

boolean contains = map.containsKey(key);    //判断是否包含指定的键值

if (contains) {         //如果条件为真

System.out.println(&quot;在Map集合中包含键名&quot; + key); //输出信息

} else {

System.out.println(&quot;在Map集合中不包含键名&quot; + key);

}

}
</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/java/3614.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
