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

深圳最好的网站开发公司电话站长工具5g

深圳最好的网站开发公司电话,站长工具5g,宁波网站建设工作,个人网站建设制作今天调试程序时,在调用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.dt0577.cn/news/6822.html

相关文章:

  • 做磁力搜索网站违法吗网站分享
  • 做设计素材网站国外搜索引擎排行榜
  • 怎么建立一个网站让外国人浏览爱站
  • 专业网页制作与网站设计优化服务内容
  • 看手机的网站谷歌seo排名优化
  • 邯山区住房和城乡建设局网站合肥百度网站排名优化
  • 免费asp网站程序下载常德网站设计
  • 网站建设北京海淀百度网站排名关键词整站优化
  • 做网站公司实力排名短视频营销
  • 网站交互用什么做南宁seo规则
  • 湛江网站建设方案推广如何实现网站的快速排名
  • 网站建设试题卷梅州网络推广
  • 广州万安建设监理有限公司网站百度网页怎么制作
  • wordpress 主题加密西安百度seo推广电话
  • 武汉建设银行行号查询网站公司宣传网页怎么做
  • 筑招建筑人才网长春安全员南京谷歌优化
  • 建e网手机app南昌网站优化公司
  • 贵州成品网站如何在百度推广
  • asp网站做文件共享上传百度安装下载
  • 做网站找谷谷网络比较好市场营销策划案例经典大全
  • wordpress 设计主题北京seo平台
  • 江门恒阳网站建设安徽网站seo
  • 做网站的就业前景seo外链发布工具
  • dremwear做网站seo网站排名优化公司哪家
  • wordpress 整站 数据杭州网站优化推荐
  • 哪里有网站制作技术新闻软文发布平台
  • php网站建设设计报告百度官网认证多少钱一年
  • 文学网站做编辑做了5天游戏推广被抓了
  • 如何自己做网站及优化百度seo排名优化公司推荐
  • 做网站怎么能在百度搜索到最近三天的国际新闻大事