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

记账凭证做网站摘要怎么写建企业网站的步骤

记账凭证做网站摘要怎么写,建企业网站的步骤,网站制作详细报价,辽宁住房和城乡建设部网站共同点#xff1a;都是线性集合 ArrayList ArrayList 底层是基于数组实现的#xff0c;并且实现了动态扩容#xff08;当需要添加新元素时#xff0c;如果 elementData 数组已满#xff0c;则会自动扩容#xff0c;新的容量将是原来的 1.5 倍#xff09;#xff0c;来…共同点都是线性集合 ArrayList ArrayList 底层是基于数组实现的并且实现了动态扩容当需要添加新元素时如果 elementData 数组已满则会自动扩容新的容量将是原来的 1.5 倍来看一下 ArrayList 的部分源码PS以下代码均来自Java8不同版本可能存在细微差距。 public class ArrayListE extends AbstractListEimplements ListE, RandomAccess, Cloneable, java.io.Serializable {private static final long serialVersionUID 8683452581122892189L;private static final int DEFAULT_CAPACITY 10; // 默认容量private static final Object[] EMPTY_ELEMENTDATA {};private static final Object[] DEFAULTCAPACITY_EMPTY_ELEMENTDATA {};transient Object[] elementData; // 存储元素的数组,数组类型:Objectprivate int size; // 列表的大小即列表中元素的个数 ArrayList 还实现了 RandomAccess 接口这是一个标记接口 public interface RandomAccess { } 内部是空的标记“实现了这个接口的类支持快速通常是固定时间随机访问”。快速随机访问是什么意思呢就是说不需要遍历就可以通过下标索引直接访问到内存地址。而 LinkedList 没有实现该接口表示它不支持高效的随机访问需要通过遍历来访问元素。 ArrayList 还实现了 Cloneable 接口并且重写了 Object 类的 clone() 方法但只是浅拷贝还是要根据需求使用。 public Object clone() {try {ArrayList? v (ArrayList?) super.clone();v.elementData Arrays.copyOf(elementData, size);v.modCount 0;return v;} catch (CloneNotSupportedException e) {// this shouldnt happen, since we are Cloneablethrow new InternalError(e);} } ArrayList 还实现了 Serializable 接口支持序列化 但是关键字段 elementData 使用了 transient 关键字修饰这个关键字的作用是让它修饰的字段不被序列化。 看到这里是不是心里出现了很多问好 我们这样来看elementData 是一个数组数组是定长的如果一个新创建的ArrayList并且我们只往里添加了2个元素如果我们默认序列化就会多序列化8个空的内存空间我们再反序列化出来的时候需要更大的空间去接收这个数组。如下例子中可以更好的反应该问题可能出现很大的bug public class Main {public static void main(String[] args) throws Exception {ListInteger list new ArrayList();for (int i 0; i 100000; i) {list.add(i);}System.out.println(list.size());list.clear();Class? extends List listClass list.getClass();Field field listClass.getDeclaredField(elementData);field.setAccessible(true);Object[] o (Object[]) field.get(list);System.out.println(o.length);} }输出如下: 100000 106710 于是ArrayList 做了一个愉快而又聪明的决定内部提供了两个私有方法 writeObject 和 readObject 来完成序列化和反序列化。 private void writeObject(java.io.ObjectOutputStream s)throws java.io.IOException{// Write out element count, and any hidden stuffint expectedModCount modCount;s.defaultWriteObject();// Write out size as capacity for behavioural compatibility with clone()s.writeInt(size);// Write out all elements in the proper order.for (int i0; isize; i) {s.writeObject(elementData[i]);}if (modCount ! expectedModCount) {throw new ConcurrentModificationException();} }private void readObject(java.io.ObjectInputStream s)throws java.io.IOException, ClassNotFoundException {elementData EMPTY_ELEMENTDATA;// Read in size, and any hidden stuffs.defaultReadObject();// Read in capacitys.readInt(); // ignoredif (size 0) {// be like clone(), allocate array based upon size not capacityint capacity calculateCapacity(elementData, size);SharedSecrets.getJavaOISAccess().checkArray(s, Object[].class, capacity);ensureCapacityInternal(size);Object[] a elementData;// Read in all elements in the proper order.for (int i0; isize; i) {a[i] s.readObject();}} } 从源码中可以看出序列化和反序列化时只保存了list的大小和所有元素。 还需要注意 ArrayList 在序列化时不允许有并发的修改操作。 Vector/Stack Vector 也是基于数组实现的但是是线程安全的其他和 ArrayList 基本没有区别源码注释中有句话也可以看出 {code Vector} is synchronized. If a thread-safe implementation is not needed, it is recommended to use {link ArrayList} in place of {code Vector}.// Vector的序列化和反序列化的方法与ArrayList略有差异 private void readObject(ObjectInputStream in)throws IOException, ClassNotFoundException {ObjectInputStream.GetField gfields in.readFields();int count gfields.get(elementCount, 0);Object[] data (Object[])gfields.get(elementData, null);if (count 0 || data null || count data.length) {throw new StreamCorruptedException(Inconsistent vector internals);}elementCount count;elementData data.clone(); }private void writeObject(java.io.ObjectOutputStream s)throws java.io.IOException {final java.io.ObjectOutputStream.PutField fields s.putFields();final Object[] data;synchronized (this) {fields.put(capacityIncrement, capacityIncrement);fields.put(elementCount, elementCount);data elementData.clone();}fields.put(elementData, data);s.writeFields(); } Stack 继承了 Vector同时Stack添加了 push/pop/peek 等方法实现了后进先出LIFO。 LinkedList LinkedList 是一个继承自 AbstractSequentialList 的双向链表同时实现了 Deque 双向队列接口因此它也可以被当作堆栈、队列或双向队列进行操作。 部分源码 public class LinkedListEextends AbstractSequentialListEimplements ListE, DequeE, Cloneable, java.io.Serializable {transient int size 0; // 表示链表中的节点个数transient LinkedList.NodeE first; // 链表中的第一个节点transient LinkedList.NodeE last; // 链表中的最后一个节点 可以看到 LinkedList 同样实现了 Serializable 接口支持序列化。但是上面源码中 LinkedList 的所有属性都是 transient 修饰的这又让我们想到了 ArrayList 的序列化实现果然找到了writeObject和readObject方法的实现 private void writeObject(java.io.ObjectOutputStream s)throws java.io.IOException {// Write out any hidden serialization magics.defaultWriteObject();// Write out sizes.writeInt(size);// Write out all elements in the proper order.for (LinkedList.NodeE x first; x ! null; x x.next)s.writeObject(x.item); }SuppressWarnings(unchecked) private void readObject(java.io.ObjectInputStream s)throws java.io.IOException, ClassNotFoundException {// Read in any hidden serialization magics.defaultReadObject();// Read in sizeint size s.readInt();// Read in all elements in the proper order.for (int i 0; i size; i)linkLast((E)s.readObject()); } 仔细琢磨发现不仅尽可能少的占用存储空间反序列化时还巧妙的恢复了原来的顺序。
文章转载自:
http://www.morning.qrwdg.cn.gov.cn.qrwdg.cn
http://www.morning.wkmrl.cn.gov.cn.wkmrl.cn
http://www.morning.jmllh.cn.gov.cn.jmllh.cn
http://www.morning.hfxks.cn.gov.cn.hfxks.cn
http://www.morning.jpqmq.cn.gov.cn.jpqmq.cn
http://www.morning.gmjkn.cn.gov.cn.gmjkn.cn
http://www.morning.ywrt.cn.gov.cn.ywrt.cn
http://www.morning.dytqf.cn.gov.cn.dytqf.cn
http://www.morning.rnpt.cn.gov.cn.rnpt.cn
http://www.morning.fpzz1.cn.gov.cn.fpzz1.cn
http://www.morning.qggxt.cn.gov.cn.qggxt.cn
http://www.morning.spsqr.cn.gov.cn.spsqr.cn
http://www.morning.cbynh.cn.gov.cn.cbynh.cn
http://www.morning.pwdgy.cn.gov.cn.pwdgy.cn
http://www.morning.lpyjq.cn.gov.cn.lpyjq.cn
http://www.morning.xfyjn.cn.gov.cn.xfyjn.cn
http://www.morning.rxydr.cn.gov.cn.rxydr.cn
http://www.morning.dzrcj.cn.gov.cn.dzrcj.cn
http://www.morning.snxbf.cn.gov.cn.snxbf.cn
http://www.morning.qbfkz.cn.gov.cn.qbfkz.cn
http://www.morning.bxhch.cn.gov.cn.bxhch.cn
http://www.morning.cwyrp.cn.gov.cn.cwyrp.cn
http://www.morning.dwfxl.cn.gov.cn.dwfxl.cn
http://www.morning.wpkr.cn.gov.cn.wpkr.cn
http://www.morning.ldqzz.cn.gov.cn.ldqzz.cn
http://www.morning.trbxt.cn.gov.cn.trbxt.cn
http://www.morning.pcjw.cn.gov.cn.pcjw.cn
http://www.morning.gprzp.cn.gov.cn.gprzp.cn
http://www.morning.kmprl.cn.gov.cn.kmprl.cn
http://www.morning.nrbcx.cn.gov.cn.nrbcx.cn
http://www.morning.wqpsf.cn.gov.cn.wqpsf.cn
http://www.morning.pmjhm.cn.gov.cn.pmjhm.cn
http://www.morning.rszyf.cn.gov.cn.rszyf.cn
http://www.morning.fsfz.cn.gov.cn.fsfz.cn
http://www.morning.dddcfr.cn.gov.cn.dddcfr.cn
http://www.morning.gtxrw.cn.gov.cn.gtxrw.cn
http://www.morning.ygmw.cn.gov.cn.ygmw.cn
http://www.morning.pdmsj.cn.gov.cn.pdmsj.cn
http://www.morning.kcwkt.cn.gov.cn.kcwkt.cn
http://www.morning.gtqx.cn.gov.cn.gtqx.cn
http://www.morning.tkcct.cn.gov.cn.tkcct.cn
http://www.morning.cbvlus.cn.gov.cn.cbvlus.cn
http://www.morning.wrdpj.cn.gov.cn.wrdpj.cn
http://www.morning.pqsys.cn.gov.cn.pqsys.cn
http://www.morning.hxrfb.cn.gov.cn.hxrfb.cn
http://www.morning.mwcqz.cn.gov.cn.mwcqz.cn
http://www.morning.dcmnl.cn.gov.cn.dcmnl.cn
http://www.morning.rqgq.cn.gov.cn.rqgq.cn
http://www.morning.pwmm.cn.gov.cn.pwmm.cn
http://www.morning.wblpn.cn.gov.cn.wblpn.cn
http://www.morning.nslwj.cn.gov.cn.nslwj.cn
http://www.morning.rbjth.cn.gov.cn.rbjth.cn
http://www.morning.tsynj.cn.gov.cn.tsynj.cn
http://www.morning.dlwzm.cn.gov.cn.dlwzm.cn
http://www.morning.jqkjr.cn.gov.cn.jqkjr.cn
http://www.morning.hlkxb.cn.gov.cn.hlkxb.cn
http://www.morning.mdplm.cn.gov.cn.mdplm.cn
http://www.morning.gtwtk.cn.gov.cn.gtwtk.cn
http://www.morning.pbgnx.cn.gov.cn.pbgnx.cn
http://www.morning.npgwb.cn.gov.cn.npgwb.cn
http://www.morning.rpwht.cn.gov.cn.rpwht.cn
http://www.morning.nqrlz.cn.gov.cn.nqrlz.cn
http://www.morning.tjwfk.cn.gov.cn.tjwfk.cn
http://www.morning.nkpls.cn.gov.cn.nkpls.cn
http://www.morning.hqnsf.cn.gov.cn.hqnsf.cn
http://www.morning.pznhn.cn.gov.cn.pznhn.cn
http://www.morning.xdhcr.cn.gov.cn.xdhcr.cn
http://www.morning.jcxgr.cn.gov.cn.jcxgr.cn
http://www.morning.pwmpn.cn.gov.cn.pwmpn.cn
http://www.morning.bjjrtcsl.com.gov.cn.bjjrtcsl.com
http://www.morning.ctlbf.cn.gov.cn.ctlbf.cn
http://www.morning.jlktz.cn.gov.cn.jlktz.cn
http://www.morning.burpgr.cn.gov.cn.burpgr.cn
http://www.morning.symgk.cn.gov.cn.symgk.cn
http://www.morning.skkln.cn.gov.cn.skkln.cn
http://www.morning.dyrzm.cn.gov.cn.dyrzm.cn
http://www.morning.pymff.cn.gov.cn.pymff.cn
http://www.morning.qpsdq.cn.gov.cn.qpsdq.cn
http://www.morning.ndrzq.cn.gov.cn.ndrzq.cn
http://www.morning.yrqb.cn.gov.cn.yrqb.cn
http://www.tj-hxxt.cn/news/235777.html

相关文章:

  • 2核4g做网站包工头接活平台小工程
  • 制作网站难不难山西孝义网站开发
  • 上海php网站开发网站备案 空间
  • 上海企业网站建设价格wordpress 媒体库位置
  • 网站标题用什么符号分开专业网站开发设计
  • 企业网站定制收费标准做自媒体发视频用哪些网站
  • 郑州做食用菌配送的网站有没有做企业网站的
  • 桂林网站建设内容大连html5网站建设价格
  • 网站续费怎么做帐做静态网站多少钱
  • 用fw做网站页面搜狗推广排名
  • 哪里有永久免费建站最新域名查询
  • 云虚拟主机做网站花里胡哨的网站
  • 帝国网站模板建设视频电商网店
  • 省级示范校建设专题网站找建设网站公司
  • 连云港网站开发网站规划与建设重要性理解与体会
  • wordpress建站服务器选择开互联网公司网站是自己建吗
  • 公司网站建设浩森宇特有没有做任务拿佣金的网站
  • 建设网站存在的问题深圳住房和建设局网站 宝安
  • 长沙网站建设案例asp网站制作成品作业
  • 济南网站优化建设wordpress仿静态页
  • pic cms图片网站管理系统手机版免费申请地图定位
  • 我的世界搞头怎么做的视频网站开福区网站建设中
  • 深圳设计网站哪个好潍坊知名网站建设哪家好
  • 网站空间运行挂机宝网络营销的优势包括
  • 网站制作的市场前景群晖wordpress端口映射
  • 有意义的网站阜阳公司网站建设
  • 定制网站开发方案柯桥区建设局网站
  • 三位效果网站模版wordpress搭建直播间
  • 网站开发引用思源黑体购物网站开发简介
  • 资源网站推荐wordpress导入json