当前位置: 首页 > news >正文

广州营销网站建设设计网站推广推广

广州营销网站建设设计,网站推广推广,手机网站生成工具,做电路方案设计的网站今天调试程序时,在调用Properties类的setProperty(String key, String value)方法时,遇到了一个小问题,程序运行到该语句时抛出异常,提示java.lang.NullPointerException,调查了半天,发现问题出在调用setPr…
今天调试程序时,在调用Properties类的setProperty(String key, String value)方法时,遇到了一个小问题,程序运行到该语句时抛出异常,提示java.lang.NullPointerException,调查了半天,发现问题出在调用setProperty(String key, String value)时,传递给该方法的value参数的值为null,由于调用setProperty(String key, String value)方法时,它会去调用Hashtable类中的public synchronized Object put(Object key, Object value)方法,查看该方法的源代码实现,代码的开始处就给出了答案:
 1ExpandedBlockStart.gifContractedBlock.gifpublic synchronized Object put(Object key, Object value)  {
 2InBlock.gif    // Make sure the value is not null

 3ExpandedSubBlockStart.gifContractedSubBlock.gif    if (value == null{
 4InBlock.gif        throw new
 NullPointerException();
 5ExpandedSubBlockEnd.gif    }

 6InBlock.gif
 7InBlock.gif    // Makes sure the key is not already in the hashtable.

 8InBlock.gif    Entry tab[] = table;
 9InBlock.gif    int hash =
 key.hashCode();
10InBlock.gif    int index = (hash & 0x7FFFFFFF%
 tab.length;
11ExpandedSubBlockStart.gifContractedSubBlock.gif    for (Entry e = tab[index] ; e != null ; e = e.next) 
{
12ExpandedSubBlockStart.gifContractedSubBlock.gif        if ((e.hash == hash) && e.key.equals(key)) 
{
13InBlock.gif        Object old =
 e.value;
14InBlock.gif        e.value =
 value;
15InBlock.gif        return
 old;
16ExpandedSubBlockEnd.gif        }

17ExpandedSubBlockEnd.gif    }

18InBlock.gif
19InBlock.gif    modCount++
;
20ExpandedSubBlockStart.gifContractedSubBlock.gif    if (count >= threshold) 
{
21InBlock.gif        // Rehash the table if the threshold is exceeded

22InBlock.gif        rehash();
23
InBlock.gif
24InBlock.gif            tab =
 table;
25InBlock.gif            index = (hash & 0x7FFFFFFF%
 tab.length;
26ExpandedSubBlockEnd.gif    }
 
27
InBlock.gif
28InBlock.gif    // Creates the new entry.

29InBlock.gif    Entry e = new Entry(hash, key, value, tab[index]);
30InBlock.gif    tab[index] =
 e;
31InBlock.gif    count++
;
32InBlock.gif    return null
;
33ExpandedBlockEnd.gif    }

就此,问题的根源找到了,以后写程序的时候得多注意这些细节。以下附上setProperty(String key, String value)方法的描述:
 1None.gif Object java.util.Properties.setProperty(String key, String value)
 2None.gifCalls the Hashtable method put. Provided for parallelism with the getProperty method. Enforces use of strings for
 property keys and values. The value returned is the result of the Hashtable call to put. 
 3
None.gif
 4
None.gifSee Also:
 5
None.gifgetProperty

 6
None.gifParameters:
 7None.gifkey: the key to be placed into this
 property list.
 8
None.gifvalue: the value corresponding to key.

 9
None.gifReturns:
10None.gifthe previous value of the specified key in this property list, or null if
 it did not have one.

11
None.gifSince: 1.2

转载于:https://www.cnblogs.com/xxpal/articles/837400.html

http://www.ds6.com.cn/news/13852.html

相关文章:

  • 网站页面设计图是用什么软件画的网站推广关键词排名优化
  • 中国十大购物软件排行上海专业seo
  • ps做全屏网站画布要多大长沙网络优化产品
  • 昆山市建设局网站百度seo关键词排名价格
  • 海外服务器加速烟台seo关键词排名
  • 网站制作加教程视频海外推广渠道都有哪些
  • 自己做的网站怎么爬数据库广东seo推广方案
  • 德源网站建设网站建设制作费用
  • 厂 网站 南宁素材网
  • 网站建设和网站推广可以同一家做吗百度seo公司哪家好一点
  • 有免费建站的网站广告资源对接平台
  • 怎么做区块链网站外链网
  • 如何制作网站导航sem是什么显微镜
  • 深圳建设网站公司排名怎么做电商卖东西
  • h网站建设百度教育网站
  • 我想建立一个网站不知道怎么做啊网络营销师证书有用吗
  • 中国建设网官网网站手游推广平台代理
  • 网站建设开发客户开场白长春关键词优化排名
  • 建站行业市场分析东莞免费网站建设网络营销
  • 太原网站建设哪家强专业网站优化培训
  • 深圳网站建设黄浦网络推广普通话手抄报模板可打印
  • 动易如何做网站seo短期课程
  • 物业管理网站开发背景互联网平台有哪些
  • 成都企业网站建设哪家专业谷歌seo运营
  • 家庭电脑可以做网站吗产品网络推广的方法有哪些
  • 划分切片来做网站关键词快速排名不限行业
  • java可以用来做网站吗网络营销管理系统
  • 设计网站需要用到哪些技术搞一个公司网站得多少钱
  • 怎么样做国外推广网站营销推广投放平台
  • 昆明做网站设计优化一下