1. package java.util;
  2.  
  3. public abstract class AbstractList<E> extends AbstractCollection<E> implements List<E> {
  4. /**
  5. * Sole constructor. (For invocation by subclass constructors, typically
  6. * implicit.)
  7. */
  8. protected AbstractList() {
  9. }
  10.  
  11. /**
  12. * Appends the specified element to the end of this list (optional
  13. * operation).
  14. *
  15. * <p>Lists that support this operation may place limitations on what
  16. * elements may be added to this list. In particular, some
  17. * lists will refuse to add null elements, and others will impose
  18. * restrictions on the type of elements that may be added. List
  19. * classes should clearly specify in their documentation any restrictions
  20. * on what elements may be added.
  21. *
  22. * <p>This implementation calls {@code add(size(), e)}.
  23. *
  24. * <p>Note that this implementation throws an
  25. * {@code UnsupportedOperationException} unless
  26. * {@link #add(int, Object) add(int, E)} is overridden.
  27. *
  28. * @param e element to be appended to this list
  29. * @return {@code true} (as specified by {@link Collection#add})
  30. * @throws UnsupportedOperationException if the {@code add} operation
  31. * is not supported by this list
  32. * @throws ClassCastException if the class of the specified element
  33. * prevents it from being added to this list
  34. * @throws NullPointerException if the specified element is null and this
  35. * list does not permit null elements
  36. * @throws IllegalArgumentException if some property of this element
  37. * prevents it from being added to this list
  38. */
  39. public boolean add(E e) {
  40. add(size(), e);
  41. return true;
  42. }
  43.  
  44. /**
  45. * {@inheritDoc}
  46. *
  47. * @throws IndexOutOfBoundsException {@inheritDoc}
  48. */
  49. abstract public E get(int index);
  50.  
  51. /**
  52. * {@inheritDoc}
  53. *
  54. * <p>This implementation always throws an
  55. * {@code UnsupportedOperationException}.
  56. *
  57. * @throws UnsupportedOperationException {@inheritDoc}
  58. * @throws ClassCastException {@inheritDoc}
  59. * @throws NullPointerException {@inheritDoc}
  60. * @throws IllegalArgumentException {@inheritDoc}
  61. * @throws IndexOutOfBoundsException {@inheritDoc}
  62. */
  63. public E set(int index, E element) {
  64. throw new UnsupportedOperationException();
  65. }
  66.  
  67. /**
  68. * {@inheritDoc}
  69. *
  70. * <p>This implementation always throws an
  71. * {@code UnsupportedOperationException}.
  72. *
  73. * @throws UnsupportedOperationException {@inheritDoc}
  74. * @throws ClassCastException {@inheritDoc}
  75. * @throws NullPointerException {@inheritDoc}
  76. * @throws IllegalArgumentException {@inheritDoc}
  77. * @throws IndexOutOfBoundsException {@inheritDoc}
  78. */
  79. public void add(int index, E element) {
  80. throw new UnsupportedOperationException();
  81. }
  82.  
  83. /**
  84. * {@inheritDoc}
  85. *
  86. * <p>This implementation always throws an
  87. * {@code UnsupportedOperationException}.
  88. *
  89. * @throws UnsupportedOperationException {@inheritDoc}
  90. * @throws IndexOutOfBoundsException {@inheritDoc}
  91. */
  92. public E remove(int index) {
  93. throw new UnsupportedOperationException();
  94. }
  95.  
  96. // Search Operations
  97.  
  98. /**
  99. * {@inheritDoc}
  100. *
  101. * <p>This implementation first gets a list iterator (with
  102. * {@code listIterator()}). Then, it iterates over the list until the
  103. * specified element is found or the end of the list is reached.
  104. *
  105. * @throws ClassCastException {@inheritDoc}
  106. * @throws NullPointerException {@inheritDoc}
  107. */
  108. public int indexOf(Object o) {
  109. ListIterator<E> it = listIterator();
  110. if (o==null) {
  111. while (it.hasNext())
  112. if (it.next()==null)
  113. return it.previousIndex();
  114. } else {
  115. while (it.hasNext())
  116. if (o.equals(it.next()))
  117. return it.previousIndex();
  118. }
  119. return -1;
  120. }
  121.  
  122. /**
  123. * {@inheritDoc}
  124. *
  125. * <p>This implementation first gets a list iterator that points to the end
  126. * of the list (with {@code listIterator(size())}). Then, it iterates
  127. * backwards over the list until the specified element is found, or the
  128. * beginning of the list is reached.
  129. *
  130. * @throws ClassCastException {@inheritDoc}
  131. * @throws NullPointerException {@inheritDoc}
  132. */
  133. public int lastIndexOf(Object o) {
  134. ListIterator<E> it = listIterator(size());
  135. if (o==null) {
  136. while (it.hasPrevious())
  137. if (it.previous()==null)
  138. return it.nextIndex();
  139. } else {
  140. while (it.hasPrevious())
  141. if (o.equals(it.previous()))
  142. return it.nextIndex();
  143. }
  144. return -1;
  145. }
  146.  
  147. // Bulk Operations
  148.  
  149. /**
  150. * Removes all of the elements from this list (optional operation).
  151. * The list will be empty after this call returns.
  152. *
  153. * <p>This implementation calls {@code removeRange(0, size())}.
  154. *
  155. * <p>Note that this implementation throws an
  156. * {@code UnsupportedOperationException} unless {@code remove(int
  157. * index)} or {@code removeRange(int fromIndex, int toIndex)} is
  158. * overridden.
  159. *
  160. * @throws UnsupportedOperationException if the {@code clear} operation
  161. * is not supported by this list
  162. */
  163. public void clear() {
  164. removeRange(0, size());
  165. }
  166.  
  167. /**
  168. * {@inheritDoc}
  169. *
  170. * <p>This implementation gets an iterator over the specified collection
  171. * and iterates over it, inserting the elements obtained from the
  172. * iterator into this list at the appropriate position, one at a time,
  173. * using {@code add(int, E)}.
  174. * Many implementations will override this method for efficiency.
  175. *
  176. * <p>Note that this implementation throws an
  177. * {@code UnsupportedOperationException} unless
  178. * {@link #add(int, Object) add(int, E)} is overridden.
  179. *
  180. * @throws UnsupportedOperationException {@inheritDoc}
  181. * @throws ClassCastException {@inheritDoc}
  182. * @throws NullPointerException {@inheritDoc}
  183. * @throws IllegalArgumentException {@inheritDoc}
  184. * @throws IndexOutOfBoundsException {@inheritDoc}
  185. */
  186. public boolean addAll(int index, Collection<? extends E> c) {
  187. rangeCheckForAdd(index);
  188. boolean modified = false;
  189. for (E e : c) {
  190. add(index++, e);
  191. modified = true;
  192. }
  193. return modified;
  194. }
  195.  
  196. // Iterators
  197.  
  198. /**
  199. * Returns an iterator over the elements in this list in proper sequence.
  200. *
  201. * <p>This implementation returns a straightforward implementation of the
  202. * iterator interface, relying on the backing list's {@code size()},
  203. * {@code get(int)}, and {@code remove(int)} methods.
  204. *
  205. * <p>Note that the iterator returned by this method will throw an
  206. * {@link UnsupportedOperationException} in response to its
  207. * {@code remove} method unless the list's {@code remove(int)} method is
  208. * overridden.
  209. *
  210. * <p>This implementation can be made to throw runtime exceptions in the
  211. * face of concurrent modification, as described in the specification
  212. * for the (protected) {@link #modCount} field.
  213. *
  214. * @return an iterator over the elements in this list in proper sequence
  215. */
  216. public Iterator<E> iterator() {
  217. return new Itr();
  218. }
  219.  
  220. /**
  221. * {@inheritDoc}
  222. *
  223. * <p>This implementation returns {@code listIterator(0)}.
  224. *
  225. * @see #listIterator(int)
  226. */
  227. public ListIterator<E> listIterator() {
  228. return listIterator(0);
  229. }
  230.  
  231. /**
  232. * {@inheritDoc}
  233. *
  234. * <p>This implementation returns a straightforward implementation of the
  235. * {@code ListIterator} interface that extends the implementation of the
  236. * {@code Iterator} interface returned by the {@code iterator()} method.
  237. * The {@code ListIterator} implementation relies on the backing list's
  238. * {@code get(int)}, {@code set(int, E)}, {@code add(int, E)}
  239. * and {@code remove(int)} methods.
  240. *
  241. * <p>Note that the list iterator returned by this implementation will
  242. * throw an {@link UnsupportedOperationException} in response to its
  243. * {@code remove}, {@code set} and {@code add} methods unless the
  244. * list's {@code remove(int)}, {@code set(int, E)}, and
  245. * {@code add(int, E)} methods are overridden.
  246. *
  247. * <p>This implementation can be made to throw runtime exceptions in the
  248. * face of concurrent modification, as described in the specification for
  249. * the (protected) {@link #modCount} field.
  250. *
  251. * @throws IndexOutOfBoundsException {@inheritDoc}
  252. */
  253. public ListIterator<E> listIterator(final int index) {
  254. rangeCheckForAdd(index);
  255.  
  256. return new ListItr(index);
  257. }
  258.  
  259. private class Itr implements Iterator<E> {
  260. /**
  261. * Index of element to be returned by subsequent call to next.
  262. */
  263. int cursor = 0;
  264.  
  265. /**
  266. * Index of element returned by most recent call to next or
  267. * previous. Reset to -1 if this element is deleted by a call
  268. * to remove.
  269. */
  270. int lastRet = -1;
  271.  
  272. /**
  273. * The modCount value that the iterator believes that the backing
  274. * List should have. If this expectation is violated, the iterator
  275. * has detected concurrent modification.
  276. */
  277. int expectedModCount = modCount;
  278.  
  279. public boolean hasNext() {
  280. return cursor != size();
  281. }
  282.  
  283. public E next() {
  284. checkForComodification();
  285. try {
  286. int i = cursor;
  287. E next = get(i);
  288. lastRet = i;
  289. cursor = i + 1;
  290. return next;
  291. } catch (IndexOutOfBoundsException e) {
  292. checkForComodification();
  293. throw new NoSuchElementException();
  294. }
  295. }
  296.  
  297. public void remove() {
  298. if (lastRet < 0)
  299. throw new IllegalStateException();
  300. checkForComodification();
  301.  
  302. try {
  303. AbstractList.this.remove(lastRet);
  304. if (lastRet < cursor)
  305. cursor--;
  306. lastRet = -1;
  307. expectedModCount = modCount;
  308. } catch (IndexOutOfBoundsException e) {
  309. throw new ConcurrentModificationException();
  310. }
  311. }
  312.  
  313. final void checkForComodification() {
  314. if (modCount != expectedModCount)
  315. throw new ConcurrentModificationException();
  316. }
  317. }
  318.  
  319. private class ListItr extends Itr implements ListIterator<E> {
  320. ListItr(int index) {
  321. cursor = index;
  322. }
  323.  
  324. public boolean hasPrevious() {
  325. return cursor != 0;
  326. }
  327.  
  328. public E previous() {
  329. checkForComodification();
  330. try {
  331. int i = cursor - 1;
  332. E previous = get(i);
  333. lastRet = cursor = i;
  334. return previous;
  335. } catch (IndexOutOfBoundsException e) {
  336. checkForComodification();
  337. throw new NoSuchElementException();
  338. }
  339. }
  340.  
  341. public int nextIndex() {
  342. return cursor;
  343. }
  344.  
  345. public int previousIndex() {
  346. return cursor-1;
  347. }
  348.  
  349. public void set(E e) {
  350. if (lastRet < 0)
  351. throw new IllegalStateException();
  352. checkForComodification();
  353.  
  354. try {
  355. AbstractList.this.set(lastRet, e);
  356. expectedModCount = modCount;
  357. } catch (IndexOutOfBoundsException ex) {
  358. throw new ConcurrentModificationException();
  359. }
  360. }
  361.  
  362. public void add(E e) {
  363. checkForComodification();
  364.  
  365. try {
  366. int i = cursor;
  367. AbstractList.this.add(i, e);
  368. lastRet = -1;
  369. cursor = i + 1;
  370. expectedModCount = modCount;
  371. } catch (IndexOutOfBoundsException ex) {
  372. throw new ConcurrentModificationException();
  373. }
  374. }
  375. }
  376.  
  377. /**
  378. * {@inheritDoc}
  379. *
  380. * <p>This implementation returns a list that subclasses
  381. * {@code AbstractList}. The subclass stores, in private fields, the
  382. * offset of the subList within the backing list, the size of the subList
  383. * (which can change over its lifetime), and the expected
  384. * {@code modCount} value of the backing list. There are two variants
  385. * of the subclass, one of which implements {@code RandomAccess}.
  386. * If this list implements {@code RandomAccess} the returned list will
  387. * be an instance of the subclass that implements {@code RandomAccess}.
  388. *
  389. * <p>The subclass's {@code set(int, E)}, {@code get(int)},
  390. * {@code add(int, E)}, {@code remove(int)}, {@code addAll(int,
  391. * Collection)} and {@code removeRange(int, int)} methods all
  392. * delegate to the corresponding methods on the backing abstract list,
  393. * after bounds-checking the index and adjusting for the offset. The
  394. * {@code addAll(Collection c)} method merely returns {@code addAll(size,
  395. * c)}.
  396. *
  397. * <p>The {@code listIterator(int)} method returns a "wrapper object"
  398. * over a list iterator on the backing list, which is created with the
  399. * corresponding method on the backing list. The {@code iterator} method
  400. * merely returns {@code listIterator()}, and the {@code size} method
  401. * merely returns the subclass's {@code size} field.
  402. *
  403. * <p>All methods first check to see if the actual {@code modCount} of
  404. * the backing list is equal to its expected value, and throw a
  405. * {@code ConcurrentModificationException} if it is not.
  406. *
  407. * @throws IndexOutOfBoundsException if an endpoint index value is out of range
  408. * {@code (fromIndex < 0 || toIndex > size)}
  409. * @throws IllegalArgumentException if the endpoint indices are out of order
  410. * {@code (fromIndex > toIndex)}
  411. */
  412. public List<E> subList(int fromIndex, int toIndex) {
  413. return (this instanceof RandomAccess ?
  414. new RandomAccessSubList<>(this, fromIndex, toIndex) :
  415. new SubList<>(this, fromIndex, toIndex));
  416. }
  417.  
  418. // Comparison and hashing
  419.  
  420. /**
  421. * Compares the specified object with this list for equality. Returns
  422. * {@code true} if and only if the specified object is also a list, both
  423. * lists have the same size, and all corresponding pairs of elements in
  424. * the two lists are <i>equal</i>. (Two elements {@code e1} and
  425. * {@code e2} are <i>equal</i> if {@code (e1==null ? e2==null :
  426. * e1.equals(e2))}.) In other words, two lists are defined to be
  427. * equal if they contain the same elements in the same order.<p>
  428. *
  429. * This implementation first checks if the specified object is this
  430. * list. If so, it returns {@code true}; if not, it checks if the
  431. * specified object is a list. If not, it returns {@code false}; if so,
  432. * it iterates over both lists, comparing corresponding pairs of elements.
  433. * If any comparison returns {@code false}, this method returns
  434. * {@code false}. If either iterator runs out of elements before the
  435. * other it returns {@code false} (as the lists are of unequal length);
  436. * otherwise it returns {@code true} when the iterations complete.
  437. *
  438. * @param o the object to be compared for equality with this list
  439. * @return {@code true} if the specified object is equal to this list
  440. */
  441. public boolean equals(Object o) {
  442. if (o == this)
  443. return true;
  444. if (!(o instanceof List))
  445. return false;
  446.  
  447. ListIterator<E> e1 = listIterator();
  448. ListIterator e2 = ((List) o).listIterator();
  449. while (e1.hasNext() && e2.hasNext()) {
  450. E o1 = e1.next();
  451. Object o2 = e2.next();
  452. if (!(o1==null ? o2==null : o1.equals(o2)))
  453. return false;
  454. }
  455. return !(e1.hasNext() || e2.hasNext());
  456. }
  457.  
  458. /**
  459. * Returns the hash code value for this list.
  460. *
  461. * <p>This implementation uses exactly the code that is used to define the
  462. * list hash function in the documentation for the {@link List#hashCode}
  463. * method.
  464. *
  465. * @return the hash code value for this list
  466. */
  467. public int hashCode() {
  468. int hashCode = 1;
  469. for (E e : this)
  470. hashCode = 31*hashCode + (e==null ? 0 : e.hashCode());
  471. return hashCode;
  472. }
  473.  
  474. /**
  475. * Removes from this list all of the elements whose index is between
  476. * {@code fromIndex}, inclusive, and {@code toIndex}, exclusive.
  477. * Shifts any succeeding elements to the left (reduces their index).
  478. * This call shortens the list by {@code (toIndex - fromIndex)} elements.
  479. * (If {@code toIndex==fromIndex}, this operation has no effect.)
  480. *
  481. * <p>This method is called by the {@code clear} operation on this list
  482. * and its subLists. Overriding this method to take advantage of
  483. * the internals of the list implementation can <i>substantially</i>
  484. * improve the performance of the {@code clear} operation on this list
  485. * and its subLists.
  486. *
  487. * <p>This implementation gets a list iterator positioned before
  488. * {@code fromIndex}, and repeatedly calls {@code ListIterator.next}
  489. * followed by {@code ListIterator.remove} until the entire range has
  490. * been removed. <b>Note: if {@code ListIterator.remove} requires linear
  491. * time, this implementation requires quadratic time.</b>
  492. *
  493. * @param fromIndex index of first element to be removed
  494. * @param toIndex index after last element to be removed
  495. */
  496. protected void removeRange(int fromIndex, int toIndex) {
  497. ListIterator<E> it = listIterator(fromIndex);
  498. for (int i=0, n=toIndex-fromIndex; i<n; i++) {
  499. it.next();
  500. it.remove();
  501. }
  502. }
  503.  
  504. /**
  505. * The number of times this list has been <i>structurally modified</i>.
  506. * Structural modifications are those that change the size of the
  507. * list, or otherwise perturb it in such a fashion that iterations in
  508. * progress may yield incorrect results.
  509. *
  510. * <p>This field is used by the iterator and list iterator implementation
  511. * returned by the {@code iterator} and {@code listIterator} methods.
  512. * If the value of this field changes unexpectedly, the iterator (or list
  513. * iterator) will throw a {@code ConcurrentModificationException} in
  514. * response to the {@code next}, {@code remove}, {@code previous},
  515. * {@code set} or {@code add} operations. This provides
  516. * <i>fail-fast</i> behavior, rather than non-deterministic behavior in
  517. * the face of concurrent modification during iteration.
  518. *
  519. * <p><b>Use of this field by subclasses is optional.</b> If a subclass
  520. * wishes to provide fail-fast iterators (and list iterators), then it
  521. * merely has to increment this field in its {@code add(int, E)} and
  522. * {@code remove(int)} methods (and any other methods that it overrides
  523. * that result in structural modifications to the list). A single call to
  524. * {@code add(int, E)} or {@code remove(int)} must add no more than
  525. * one to this field, or the iterators (and list iterators) will throw
  526. * bogus {@code ConcurrentModificationExceptions}. If an implementation
  527. * does not wish to provide fail-fast iterators, this field may be
  528. * ignored.
  529. */
  530. protected transient int modCount = 0;
  531.  
  532. private void rangeCheckForAdd(int index) {
  533. if (index < 0 || index > size())
  534. throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
  535. }
  536.  
  537. private String outOfBoundsMsg(int index) {
  538. return "Index: "+index+", Size: "+size();
  539. }
  540. }
  541.  
  542. class SubList<E> extends AbstractList<E> {
  543. private final AbstractList<E> l;
  544. private final int offset;
  545. private int size;
  546.  
  547. SubList(AbstractList<E> list, int fromIndex, int toIndex) {
  548. if (fromIndex < 0)
  549. throw new IndexOutOfBoundsException("fromIndex = " + fromIndex);
  550. if (toIndex > list.size())
  551. throw new IndexOutOfBoundsException("toIndex = " + toIndex);
  552. if (fromIndex > toIndex)
  553. throw new IllegalArgumentException("fromIndex(" + fromIndex +
  554. ") > toIndex(" + toIndex + ")");
  555. l = list;
  556. offset = fromIndex;
  557. size = toIndex - fromIndex;
  558. this.modCount = l.modCount;
  559. }
  560.  
  561. public E set(int index, E element) {
  562. rangeCheck(index);
  563. checkForComodification();
  564. return l.set(index+offset, element);
  565. }
  566.  
  567. public E get(int index) {
  568. rangeCheck(index);
  569. checkForComodification();
  570. return l.get(index+offset);
  571. }
  572.  
  573. public int size() {
  574. checkForComodification();
  575. return size;
  576. }
  577.  
  578. public void add(int index, E element) {
  579. rangeCheckForAdd(index);
  580. checkForComodification();
  581. l.add(index+offset, element);
  582. this.modCount = l.modCount;
  583. size++;
  584. }
  585.  
  586. public E remove(int index) {
  587. rangeCheck(index);
  588. checkForComodification();
  589. E result = l.remove(index+offset);
  590. this.modCount = l.modCount;
  591. size--;
  592. return result;
  593. }
  594.  
  595. protected void removeRange(int fromIndex, int toIndex) {
  596. checkForComodification();
  597. l.removeRange(fromIndex+offset, toIndex+offset);
  598. this.modCount = l.modCount;
  599. size -= (toIndex-fromIndex);
  600. }
  601.  
  602. public boolean addAll(Collection<? extends E> c) {
  603. return addAll(size, c);
  604. }
  605.  
  606. public boolean addAll(int index, Collection<? extends E> c) {
  607. rangeCheckForAdd(index);
  608. int cSize = c.size();
  609. if (cSize==0)
  610. return false;
  611.  
  612. checkForComodification();
  613. l.addAll(offset+index, c);
  614. this.modCount = l.modCount;
  615. size += cSize;
  616. return true;
  617. }
  618.  
  619. public Iterator<E> iterator() {
  620. return listIterator();
  621. }
  622.  
  623. public ListIterator<E> listIterator(final int index) {
  624. checkForComodification();
  625. rangeCheckForAdd(index);
  626.  
  627. return new ListIterator<E>() {
  628. private final ListIterator<E> i = l.listIterator(index+offset);
  629.  
  630. public boolean hasNext() {
  631. return nextIndex() < size;
  632. }
  633.  
  634. public E next() {
  635. if (hasNext())
  636. return i.next();
  637. else
  638. throw new NoSuchElementException();
  639. }
  640.  
  641. public boolean hasPrevious() {
  642. return previousIndex() >= 0;
  643. }
  644.  
  645. public E previous() {
  646. if (hasPrevious())
  647. return i.previous();
  648. else
  649. throw new NoSuchElementException();
  650. }
  651.  
  652. public int nextIndex() {
  653. return i.nextIndex() - offset;
  654. }
  655.  
  656. public int previousIndex() {
  657. return i.previousIndex() - offset;
  658. }
  659.  
  660. public void remove() {
  661. i.remove();
  662. SubList.this.modCount = l.modCount;
  663. size--;
  664. }
  665.  
  666. public void set(E e) {
  667. i.set(e);
  668. }
  669.  
  670. public void add(E e) {
  671. i.add(e);
  672. SubList.this.modCount = l.modCount;
  673. size++;
  674. }
  675. };
  676. }
  677.  
  678. public List<E> subList(int fromIndex, int toIndex) {
  679. return new SubList<>(this, fromIndex, toIndex);
  680. }
  681.  
  682. private void rangeCheck(int index) {
  683. if (index < 0 || index >= size)
  684. throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
  685. }
  686.  
  687. private void rangeCheckForAdd(int index) {
  688. if (index < 0 || index > size)
  689. throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
  690. }
  691.  
  692. private String outOfBoundsMsg(int index) {
  693. return "Index: "+index+", Size: "+size;
  694. }
  695.  
  696. private void checkForComodification() {
  697. if (this.modCount != l.modCount)
  698. throw new ConcurrentModificationException();
  699. }
  700. }
  701.  
  702. class RandomAccessSubList<E> extends SubList<E> implements RandomAccess {
  703. RandomAccessSubList(AbstractList<E> list, int fromIndex, int toIndex) {
  704. super(list, fromIndex, toIndex);
  705. }
  706.  
  707. public List<E> subList(int fromIndex, int toIndex) {
  708. return new RandomAccessSubList<>(this, fromIndex, toIndex);
  709. }
  710. }

  

JDK源码阅读(二) AbstractList的更多相关文章

  1. 一点一点看JDK源码(二)java.util.List

    一点一点看JDK源码(二)java.util.List liuyuhang原创,未经允许进制转载 本文举例使用的是JDK8的API 目录:一点一点看JDK源码(〇) 1.综述 List译为表,一览表, ...

  2. JDK源码阅读(三):ArraryList源码解析

    今天来看一下ArrayList的源码 目录 介绍 继承结构 属性 构造方法 add方法 remove方法 修改方法 获取元素 size()方法 isEmpty方法 clear方法 循环数组 1.介绍 ...

  3. JDK源码阅读(一):Object源码分析

    最近经过某大佬的建议准备阅读一下JDK的源码来提升一下自己 所以开始写JDK源码分析的文章 阅读JDK版本为1.8 目录 Object结构图 构造器 equals 方法 getClass 方法 has ...

  4. 利用IDEA搭建JDK源码阅读环境

    利用IDEA搭建JDK源码阅读环境 首先新建一个java基础项目 基础目录 source 源码 test 测试源码和入口 准备JDK源码 下图框起来的路径就是jdk的储存位置 打开jdk目录,找到sr ...

  5. JDK源码阅读-FileOutputStream

    本文转载自JDK源码阅读-FileOutputStream 导语 FileOutputStream用户打开文件并获取输出流. 打开文件 public FileOutputStream(File fil ...

  6. JDK源码阅读-FileInputStream

    本文转载自JDK源码阅读-FileInputStream 导语 FileIntputStream用于打开一个文件并获取输入流. 打开文件 我们来看看FileIntputStream打开文件时,做了什么 ...

  7. JDK源码阅读-ByteBuffer

    本文转载自JDK源码阅读-ByteBuffer 导语 Buffer是Java NIO中对于缓冲区的封装.在Java BIO中,所有的读写API,都是直接使用byte数组作为缓冲区的,简单直接.但是在J ...

  8. JDK源码阅读-RandomAccessFile

    本文转载自JDK源码阅读-RandomAccessFile 导语 FileInputStream只能用于读取文件,FileOutputStream只能用于写入文件,而对于同时读取文件,并且需要随意移动 ...

  9. JDK源码阅读-FileDescriptor

    本文转载自JDK源码阅读-FileDescriptor 导语 操作系统使用文件描述符来指代一个打开的文件,对文件的读写操作,都需要文件描述符作为参数.Java虽然在设计上使用了抽象程度更高的流来作为文 ...

随机推荐

  1. 理解标签重置reset

    /*样式表文件来自 懒人css http://lrcss.lrjz100.com *//*---------重置---------*/html{font-size: 100%;-webkit-text ...

  2. ubuntu 14.04 chromium,firefox 怎样正确安装Adobe flash player

    一.firefox 正确安装Adobe flash player 有时候我们须要在Ubuntu下採用手动安装一些软件,比方Firefox的Flash插件.Adobe® Flash® Player 是一 ...

  3. Linux 内核开发—内核简单介绍

    内核简单介绍 Linux 构成 Linux 为什么被划分为系统空间和内核空间 隔离核心程序和应用程序,实现对核心程序和数据的保护. 什么内核空间,用户空间 内核空间和用户空间是程序执行的两种不同的状态 ...

  4. How to manage and balance “Huge Data Load” for Big Kafka Clusters---reference

    1. Add Partition Tool Partitions act as unit of parallelism. Messages of a single topic are distribu ...

  5. linux下的openoffice安装和服务自启动

    openoffice下载并安装 wget http://sourceforge.net/projects/openofficeorg.mirror/files/4.1.1/binaries/zh-CN ...

  6. GitHub安装失败

    安装GitHub客户端的时候,会提示失败,如下: An error occurred trying to download 'http://github-windows.s3.amazonaws.co ...

  7. Java实现微信菜单json字符串拼接

    Java实现微信菜单json字符串拼接 微信菜单拼接json字符串方法 >>>>>>>>>>>>>>>> ...

  8. burp

    http://www.2cto.com/Article/201406/310929.html

  9. Big Data 應用:第二季(4~6月)台湾地区Game APP 变动分布趋势图

    图表简介: 该示意图表示了台湾地区第二季内所有Game APP类别的分布情形,经由该图表我们可以快速的了解到在这三个月内,哪类型的APP是很稳定:抑或者哪类型的APP是非常不稳定的. 名词解释: 类别 ...

  10. 锱铢必较,从(function(){}())与(function(){})()说起

    今天做JsHint时,碰到一个警告:应该使用(function(){}())而不是(function(){})();看到这个我心想,这两种函数自执行有什么区别吗?自执行用了这么久,感觉对其理解仍然有点 ...