自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

大德如危的博客

不积跬步无以至千里 不积小流无以成江海

  • 博客(18)
  • 资源 (1)
  • 问答 (1)
  • 收藏
  • 关注

原创 Java源码剖析之IO序列化

java基本类型和许多常用库类都实现了Serializable接口,该接口允许我们对实现了其接口的类进行序列化操作,也就是保存对象的状态。我们在下面几种情况经常会使用到序列化: (1)把一个对象状态保存到文件中 (2)使用套接字传送对象时 (3)通过RMI传送对象时 下面,我们对序列化进行简单介绍。 1.基本类型和实现了Serializable接口的类都允许进行序列化 2.st

2017-03-29 21:51:34 190

原创 Java源码剖析之输入输出流

Java里的管道输入流PipedInputStream与管道输出流PipedOutputStream实现了类似管道的功能,用于不同线程之间的相互通信,下面说下自己的一些理解。 1.连接方法。 输入输出流是配套使用的,一个输出流必须与一个输入流配合才能工作。在Java的实现中,输入输出流的连接方式是:输出流中包含了输入流: private PipedInputStream sink;

2017-03-28 21:40:31 377

原创 Java源码剖析之LinkedList

LinkedLists 是我们最常用的集合之一,通过节点Node来储存元素。下面我们来剖析LinkedList源码。 我们先来查看LinkedList的基本存储单元Node: private static class Node<E> { E item; Node<E> next; Node<E> prev; Node(Nod

2017-03-28 09:50:53 256

原创 Java源码剖析之fail-fast机制

fail-fast机制是Java集合的一种错误机制。当多个线程对同一个集合进行操作时,可能就会产生fail-fast事件。比如当我们使用iterator去遍历集合的同时另一线程对该集合进行操作,就有可能抛出 java.util.ConcurrentModificationException异常,产生fail-fast事件。1.fail-fast原理我们通过ArrayList中的iterator源码剖

2017-03-28 09:45:36 308

原创 Java源码剖析之HashMap

键值对(也就是Map)是我们经常使用的一种数据结构,其中HashMap应该是我们使用最多的一种,因为它速度快,没有别的特殊需求一般我们都会使用HashMap。下面我们对它的源码进行剖析。1.单位存储对象EntryHashMap中,一个键值对使用一个Entry static class Entry<K,V> implements Map.Entry<K,V> { final K

2017-03-28 09:43:31 428

原创 Java源码剖析之HashSet

上一篇文章我们介绍了HashMap的实现,现在我们学校HashSet就很容易啦。这里提一点的是,HashMap并不是Collection接口的实现类,它只是Map1.构造方法 public HashSet() { map = new HashMap<>(); } public HashSet(Collection<? extends E> c) { m

2017-03-28 09:37:17 204

原创 Java源码剖析之Stack

栈(stack)是我们常用的基本数据结构之一,下面将简单剖析Java中stack 的数据结构。 1.类定义 public class Stack extends Vector {     stack是继承与Vector的,也就是说,它是一个list实现。同时,继承了Vector的线程安全(效率较低~)。内部是数组实现(通过增长系数来扩容,增长系数为0时翻倍扩容)。 2.构造方法。

2017-03-27 13:56:27 188

原创 Java源码剖析之Vector

之前我们已经学习了ArrayList的源码,ArrayList内置使用数组来储存数据。Vector数据结构和ArrayList很相似,也是使用数组存储。下面我们主要通过Vector与ArrayList对比来剖析Vector。     1.Vector比ArrayList多一个动态数组的增长系数capacityIncrement。在Vector的内置数组需要增加容量时,每次会根据增长系数大

2017-03-27 13:35:57 230

原创 Java源码剖析之ArrayList

ArrayList是我们最常用的链表之一,经常作为动态数组使用,今天我们将对ArrayList源码一探究竟。     1.Class定义 public class ArrayList extends AbstractList implements List, RandomAccess, Cloneable, java.io.Serializable     AbstractL

2017-03-25 14:46:54 309

原创 leetCode练习(134)(

题目:Gas Station 难度:MEDIUM 问题描述: There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of g

2017-03-13 20:43:02 264

原创 Java的++i与i++

先看一小段代码: public static void main(String[] args) { int i=1; i=i++; System.out.println(i); } 可能很多人认为结果是‘2’,因为I先赋值给自身,然后又进行了增1. 上述结论是错的!实际上,不管是前置++I,还是后置I++,都是先将变量的值加1,然后再继续计算的。 两者真正的区别是:前置

2017-03-12 10:01:04 218

原创 java的整型直接的转换

看一段小程序: public static void main(String[] args) { byte b = -10; char c = (char)b; int i = c; System.out.println(i); } 输出的结果是65526,这里做一下解释: 1.byte=-10时,补码为 1111 0110 2.转为int型,因为byte是有符号型

2017-03-11 19:51:33 268

原创 leetCode练习(494)

题目:Target Sum 难度:MEDIUM 问题描述: You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and

2017-03-07 20:06:27 392

原创 leetCode练习(187)

题目:Repeated DNA Sequences 难度:MEDIUM 问题描述: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to ident

2017-03-06 22:28:27 552

原创 leetCode练习(148)

题目:Sort List           难度:MEDIUM 问题描述: Sort a linked list in O(n log n) time using constant space complexity. Subscribe to see which companies asked this question. 解题思路:使用归并排序即可。注意模块化。 /**

2017-03-06 20:38:59 172

原创 leetCode练习(520)

题目:Detect Capital 难度:Easy 问题描述: Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of the followi

2017-03-03 16:05:43 232

原创 leetCode练习(242)

题目:Relative Ranks 难度:Easy 问题描述: Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and

2017-03-03 15:42:32 207

原创 leetCode练习(242)

题目:Valid Anagram 难度:Easy 问题描述: Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = "anagram", t = "nagaram", return true. s = "rat", t = "car"

2017-03-03 10:06:55 267

C语言打字游戏(easyx绘图版)

使用easyx库替代bc的图形库来用c绘图,效果不错,适合c语言新手增加学习兴趣。

2013-05-31

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除