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

网站后台怎么修改代码wordpress 群

网站后台怎么修改代码,wordpress 群,域名转接的流程,爱站网挖掘工具问题 如下代码#xff0c;虽然定义为非空 NonNull#xff0c;但依然会返回空对象#xff0c;导致调用侧被检测为空引用。 实际上不是Collections的问题是三目运算符返回了null对象。 import java.util.Collections;NonNullprivate ListString getInfo() {IccReco…问题 如下代码虽然定义为非空 NonNull但依然会返回空对象导致调用侧被检测为空引用。 实际上不是Collections的问题是三目运算符返回了null对象。 import java.util.Collections;NonNullprivate ListString getInfo() {IccRecords iccRecords mPhone.getIccRecords();if(iccRecords ! null) {//省略逻辑String[] simSpdi iccRecords.getServiceProviderDisplayInformation();return simSpdi ! null ? Arrays.asList(simSpdi) : null; //根因是这里返回null}return Collections.EMPTY_LIST;} 源码案例 frameworks/opt/telephony/src/java/com/android/internal/telephony/cdnr/CarrierDisplayNameResolver.java NonNullprivate ListString getEfSpdi() {for (int i 0; i mEf.size(); i) {if (mEf.valueAt(i).getServiceProviderDisplayInformation() ! null) {return mEf.valueAt(i).getServiceProviderDisplayInformation();}}return Collections.EMPTY_LIST;}NonNullprivate String getEfSpn() {for (int i 0; i mEf.size(); i) {if (!TextUtils.isEmpty(mEf.valueAt(i).getServiceProviderName())) {return mEf.valueAt(i).getServiceProviderName();}}return ;}NonNullprivate ListOperatorPlmnInfo getEfOpl() {for (int i 0; i mEf.size(); i) {if (mEf.valueAt(i).getOperatorPlmnList() ! null) {return mEf.valueAt(i).getOperatorPlmnList();}}return Collections.EMPTY_LIST;}NonNullprivate ListPlmnNetworkName getEfPnn() {for (int i 0; i mEf.size(); i) {if (mEf.valueAt(i).getPlmnNetworkNameList() ! null) {return mEf.valueAt(i).getPlmnNetworkNameList();}}return Collections.EMPTY_LIST;} 代码解析 注意Collection和Collections是不同的。 libcore/ojluni/src/main/java/java/util/Collections.java 工具类libcore/ojluni/src/main/java/java/util/Collection.java 接口 Collections中定义了内部类EmptyList在静态List常量EMPTY_LISTimmutable不可变列表初始化时会new一个没有指定类型的EmptyList。 public class Collections {/*** The empty list (immutable). This list is serializable.** see #emptyList()*/SuppressWarnings(rawtypes)public static final List EMPTY_LIST new EmptyList();/*** Returns an empty list (immutable). This list is serializable.** pThis example illustrates the type-safe way to obtain an empty list:* pre* Listlt;Stringgt; s Collections.emptyList();* /pre** implNote* Implementations of this method need not create a separate {code List}* object for each call. Using this method is likely to have comparable* cost to using the like-named field. (Unlike this method, the field does* not provide type safety.)** param T type of elements, if there were any, in the list* return an empty immutable list** see #EMPTY_LIST* since 1.5*/SuppressWarnings(unchecked)public static final T ListT emptyList() {return (ListT) EMPTY_LIST;}/*** serial include*/private static class EmptyListEextends AbstractListEimplements RandomAccess, Serializable {java.io.Serialprivate static final long serialVersionUID 8842843931221139166L;public IteratorE iterator() {return emptyIterator();}public ListIteratorE listIterator() {return emptyListIterator();}// Preserves singleton propertyjava.io.Serialprivate Object readResolve() {return EMPTY_LIST;}}} 解决方案 将 Collections.EMPTY_LIST 替换成 Collections.emptyList()。 虽然它们都可以用于表示一个空的不可变列表但 Collections.emptyList() 是更优先的选择因为它提供了类型安全性和更好的代码可读性。 附Collections 源码 一些值得学习的语法Android 扩展的排序跟Java 集合原生排序的实现差异 libcore/ojluni/src/main/java/java/util/Collections.java import dalvik.system.VMRuntime;/*** This class consists exclusively of static methods that operate on or return* collections. It contains polymorphic algorithms that operate on* collections, wrappers, which return a new collection backed by a* specified collection, and a few other odds and ends.** pThe methods of this class all throw a {code NullPointerException}* if the collections or class objects provided to them are null.** pThe documentation for the polymorphic algorithms contained in this class* generally includes a brief description of the iimplementation/i. Such* descriptions should be regarded as iimplementation notes/i, rather than* parts of the ispecification/i. Implementors should feel free to* substitute other algorithms, so long as the specification itself is adhered* to. (For example, the algorithm used by {code sort} does not have to be* a mergesort, but it does have to be istable/i.)** pThe destructive algorithms contained in this class, that is, the* algorithms that modify the collection on which they operate, are specified* to throw {code UnsupportedOperationException} if the collection does not* support the appropriate mutation primitive(s), such as the {code set}* method. These algorithms may, but are not required to, throw this* exception if an invocation would have no effect on the collection. For* example, invoking the {code sort} method on an unmodifiable list that is* already sorted may or may not throw {code UnsupportedOperationException}.** pThis class is a member of the* a href{docRoot}/java.base/java/util/package-summary.html#CollectionsFramework* Java Collections Framework/a.** author Josh Bloch* author Neal Gafter* see Collection* see Set* see List* see Map* since 1.2*/public class Collections {// Suppresses default constructor, ensuring non-instantiability.private Collections() {}// Algorithms// Android-added: List.sort() vs. Collections.sort() app compat.// Added a warning in the documentation.// Collections.sort() calls List.sort() for apps targeting API version 26// (Android Oreo) but the other way around for app targeting 25 (Nougat)./*** Sorts the specified list into ascending order, according to the* {linkplain Comparable natural ordering} of its elements.* All elements in the list must implement the {link Comparable}* interface. Furthermore, all elements in the list must be* imutually comparable/i (that is, {code e1.compareTo(e2)}* must not throw a {code ClassCastException} for any elements* {code e1} and {code e2} in the list).** pThis sort is guaranteed to be istable/i: equal elements will* not be reordered as a result of the sort.** pThe specified list must be modifiable, but need not be resizable.** implNote* This implementation defers to the {link List#sort(Comparator)}* method using the specified list and a {code null} comparator.* Do not call this method from {code List.sort()} since that can lead* to infinite recursion. Apps targeting APIs {code 25} observe* backwards compatibility behavior where this method was implemented* on top of {link List#toArray()}, {link ListIterator#next()} and* {link ListIterator#set(Object)}.** param T the class of the objects in the list* param list the list to be sorted.* throws ClassCastException if the list contains elements that are not* imutually comparable/i (for example, strings and integers).* throws UnsupportedOperationException if the specified lists* list-iterator does not support the {code set} operation.* throws IllegalArgumentException (optional) if the implementation* detects that the natural ordering of the list elements is* found to violate the {link Comparable} contract* see List#sort(Comparator)*/public static T extends Comparable? super T void sort(ListT list) {// Android-changed: List.sort() vs. Collections.sort() app compat.// Call sort(list, null) here to be consistent with that methods// (changed on Android) behavior.// list.sort(null);sort(list, null);}}
http://www.hkea.cn/news/14319038/

相关文章:

  • 网站哪里做达州网站建设yufanse
  • 吕梁网站制作吕梁安全网站360全景图怎么做
  • 深圳网站优讳化做网站的用什么电脑好
  • 电商网站开发模块跨境电商资讯网
  • 哪家专门做特卖的网站网站设计就业
  • pc wap 装修公司网站源码ps做网站心得
  • 网站开发实战上海网站建设百度推广公司
  • 摄影网站建设的意义flash个人网站欣赏
  • 苏州行业网站建设旅游网站html5代码模板
  • 网站运营学习网站规划书包括哪些方面
  • 宁波网站关键词优化代码网站建设承揽合同
  • ftp上传网站全教程凡科做的网站为什么打不开
  • 阅读网站怎样做千博医院网站模板
  • 宁波网站制作出售wordpress更改主站点
  • 北京网站优化软件公司网站套餐网页
  • 网站信息化建设方案wordpress add post meta
  • 外贸出口建站做网站的商家怎么后去流量费
  • php语言 电商网站建设网页设计与制作ppt课件
  • 外贸石材网站wordpress 图像主题
  • 华为商城网站设计分析wordpress自带的邮件系统
  • 织梦cms通用蓝白简介大气企业网站环保科技公司源码免费建站哪个网站最好
  • 衡水网站建设找谁店铺设计理念怎么写
  • 网站首页被降权的原因好的模板网站建设
  • 建网站需要多少钱和什么条件有关wordpress migrate.min.js是什么
  • 中国做爰网站个人小程序源码
  • 医院网站建设台账网站 网址 域名
  • 中国银行全球门户网站用织梦网站后台发布文章为什么还需要审核
  • 网站运营的发展方向江苏建设外贸公司网站
  • 网站插件代码怎么用教育网站建设平台
  • 传媒公司有哪些搜索引擎优化的方法与技巧