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

深圳最好的网站开发公司电话百度搜索推广平台

深圳最好的网站开发公司电话,百度搜索推广平台,wordpress外部样式,做360手机网站快速今天调试程序时,在调用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.mmbaike.com/news/68689.html

相关文章:

  • 私人路由器做网站aso优化师工作很赚钱吗
  • 松岗网站建设媒体代发网站
  • dreamweaver的主要功能深圳sem优化
  • 盘锦威旺做网站建设公司北京seo业务员
  • 做网站的费用是多少销售的技巧与口才
  • 商城小程序需要什么资质上海关键词优化排名软件
  • 足球比赛直播app下载优化推广网站seo
  • 惠州网站建设服务爱站网关键词
  • 温州做企业网站网站维护工作内容
  • 学网站开发看什么书关于进一步优化
  • 郑州的网站建设公司今日国际重大新闻
  • 北京网站定制流程上海网站排名优化
  • 网站开发工作日志万网查询
  • 嘉兴网站制作报价企业网站开发
  • 山东德州网站建设哪家最专业竞价防恶意点击
  • 打开百度竞价页面是网站是什么seo网络排名优化技巧
  • 网站设计是用什么软件做电商平台推广公司
  • 自己做流媒体网站难长沙seo霸屏
  • 手机建设银行网站百度游戏中心
  • java开发手机网站建设营销型企业网站制作
  • 用phython做网站泰州网站建设优化
  • 大连仟亿科技网站建设公司怎么样seo优化广告
  • 宣城老品牌网站建设seo刷排名公司
  • 大连企业做网站公司排名外贸高端网站设计公司
  • 如何说服别人做网站seo免费资源大全
  • 虹口做网站价格网上在线看视频为什么卡
  • 昆明seo公司网站网络营销组合策略
  • 网站内容页怎么做的十大网络营销成功案例
  • 绍兴网络科技有限公司在广州做seo找哪家公司
  • 网站建设型网站横幅(banner)图片百度互联网营销是什么