Object对象是除了基础对象之外,所有的对象都需要继承的父对象,包括数组也继承了Object

Object里面的关键函数罗列如下:

clone();调用该函数需要实现 Cloneable,否则会抛出  CloneNotSupportedException的异常。

equals();用来判断两个对象是否相等的函数,默认的是两个对象的地址比较,在使用Compare计算的时候,往往需要重写这个函数。

finalize();这个函数在对象被消解的时候,例如垃圾回收的时候等,会被调用,如果对象使用了不可被自动回收的内存空间等资源,应该在这个函数里面收回。

hashCode();返回的是这个对象的hash值,期内部的实现代码如下:

  1. int lockWord = shadow$_monitor_;
  2. final int lockWordMask = 0xC0000000; // Top 2 bits.
  3. final int lockWordStateHash = 0x80000000; // Top 2 bits are value 2 (kStateHash).
  4. if ((lockWord & lockWordMask) == lockWordStateHash) {
  5. return lockWord & ~lockWordMask;
  6. }
  7. return System.identityHashCode(this);
  1. & lockWordMask是获取最高两位,
  1. lockWordStateHash是指最高两位是210),最高位是符号位,但是不明白为什么要获取两位。
  1. return lockWord & ~lockWordMask; ~是非运算符,所以这句话是返回了除了最高两位的所有其它位的值。
  2.  
  3. 如果不满足上述条件,返回的是
  1. System.identityHashCode(this);,这个是native的方法,没有深入

notify():唤醒被这个对象的monitor标记等待的线程,如果线程的数量大于1,那么被唤醒的线程是由VM自行决定的。注意被唤醒的线程不一定立即执行,至少要等待当前调用notify的线程释放这个对象的monitor,或者等待其他正好同步锁定该对象的线程释放了该对象。 当然了,也不是任何地方都可以调用notify的,调用的地方必须持有对象的monitor,可以有以下几种情况:1.在一个同步( synchronized)方法中;2.在一段该对象的同步代码块中;3.如果这个变量是类变量(static),同步的静态方法也持有。

notifyAll(): 与上面所属的notify类似,只不过是唤醒了所有的线程,当然这些线程也不是立即执行,理由同上。

toString():这个对象的字符串描述,默认的是返回类名和实例的hashCode,代码如下:

  1. public String toString() {
  2. return getClass().getName() + '@' + Integer.toHexString(hashCode());
  3. }

wait(): 通知当前线程挂起,当对象的notify或者notifyAll被调用的时候才会被重新唤醒,wait了的thread是可以被中断(interrupt)的。当线程wait的时候,这个线程其实丢失了对象的monitor,当被notify的时候,会在程序执行前重新请求到对象的monitor。

还有两个wait函数是带参数的,参数指明了线程的wait时长,如果在这个时长内,线程没有被唤醒,那么当时间到达的时候,这个线程也会被重新唤醒。其他的与上面的wait一致,对了时间为0,说明没有超时时间,时间不可以小于零,否则抛出 IllegalArgumentException

  1. 下文中的shadow$_monitor_shadow$_klass_ Android sdk21之后Object增加的两个字段。前者好像是用来表明地址的,后者是用来说明类型的。
  2.  
  3. Android中的Object源码如下:
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /*
  18. * Copyright (C) 2008 The Android Open Source Project
  19. *
  20. * Licensed under the Apache License, Version 2.0 (the "License");
  21. * you may not use this file except in compliance with the License.
  22. * You may obtain a copy of the License at
  23. *
  24. * http://www.apache.org/licenses/LICENSE-2.0
  25. *
  26. * Unless required by applicable law or agreed to in writing, software
  27. * distributed under the License is distributed on an "AS IS" BASIS,
  28. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  29. * See the License for the specific language governing permissions and
  30. * limitations under the License.
  31. */
  32.  
  33. package java.lang;
  34.  
  35. /**
  36. * The root class of the Java class hierarchy. All non-primitive types
  37. * (including arrays) inherit either directly or indirectly from this class.
  38. *
  39. * <a name="writing_equals"><h4>Writing a correct {@code equals} method</h4></a>
  40. * <p>Follow this style to write a canonical {@code equals} method:
  41. * <pre>
  42. * // Use @Override to avoid accidental overloading.
  43. * @Override public boolean equals(Object o) {
  44. * // Return true if the objects are identical.
  45. * // (This is just an optimization, not required for correctness.)
  46. * if (this == o) {
  47. * return true;
  48. * }
  49. *
  50. * // Return false if the other object has the wrong type.
  51. * // This type may be an interface depending on the interface's specification.
  52. * if (!(o instanceof MyType)) {
  53. * return false;
  54. * }
  55. *
  56. * // Cast to the appropriate type.
  57. * // This will succeed because of the instanceof, and lets us access private fields.
  58. * MyType lhs = (MyType) o;
  59. *
  60. * // Check each field. Primitive fields, reference fields, and nullable reference
  61. * // fields are all treated differently.
  62. * return primitiveField == lhs.primitiveField &amp;&amp;
  63. * referenceField.equals(lhs.referenceField) &amp;&amp;
  64. * (nullableField == null ? lhs.nullableField == null
  65. * : nullableField.equals(lhs.nullableField));
  66. * }
  67. * </pre>
  68. * <p>If you override {@code equals}, you should also override {@code hashCode}: equal
  69. * instances must have equal hash codes.
  70. *
  71. * <p>See <i>Effective Java</i> item 8 for much more detail and clarification.
  72. *
  73. * <a name="writing_hashCode"><h4>Writing a correct {@code hashCode} method</h4></a>
  74. * <p>Follow this style to write a canonical {@code hashCode} method:
  75. * <pre>
  76. * @Override public int hashCode() {
  77. * // Start with a non-zero constant.
  78. * int result = 17;
  79. *
  80. * // Include a hash for each field.
  81. * result = 31 * result + (booleanField ? 1 : 0);
  82. *
  83. * result = 31 * result + byteField;
  84. * result = 31 * result + charField;
  85. * result = 31 * result + shortField;
  86. * result = 31 * result + intField;
  87. *
  88. * result = 31 * result + (int) (longField ^ (longField >>> 32));
  89. *
  90. * result = 31 * result + Float.floatToIntBits(floatField);
  91. *
  92. * long doubleFieldBits = Double.doubleToLongBits(doubleField);
  93. * result = 31 * result + (int) (doubleFieldBits ^ (doubleFieldBits >>> 32));
  94. *
  95. * result = 31 * result + Arrays.hashCode(arrayField);
  96. *
  97. * result = 31 * result + referenceField.hashCode();
  98. * result = 31 * result +
  99. * (nullableReferenceField == null ? 0
  100. * : nullableReferenceField.hashCode());
  101. *
  102. * return result;
  103. * }
  104. * </pre>
  105. *
  106. * <p>If you don't intend your type to be used as a hash key, don't simply rely on the default
  107. * {@code hashCode} implementation, because that silently and non-obviously breaks any future
  108. * code that does use your type as a hash key. You should throw instead:
  109. * <pre>
  110. * @Override public int hashCode() {
  111. * throw new UnsupportedOperationException();
  112. * }
  113. * </pre>
  114. *
  115. * <p>See <i>Effective Java</i> item 9 for much more detail and clarification.
  116. *
  117. * <a name="writing_toString"><h4>Writing a useful {@code toString} method</h4></a>
  118. * <p>For debugging convenience, it's common to override {@code toString} in this style:
  119. * <pre>
  120. * @Override public String toString() {
  121. * return getClass().getName() + "[" +
  122. * "primitiveField=" + primitiveField + ", " +
  123. * "referenceField=" + referenceField + ", " +
  124. * "arrayField=" + Arrays.toString(arrayField) + "]";
  125. * }
  126. * </pre>
  127. * <p>The set of fields to include is generally the same as those that would be tested
  128. * in your {@code equals} implementation.
  129. * <p>See <i>Effective Java</i> item 10 for much more detail and clarification.
  130. */
  131. public class Object {
  132.  
  133. private transient Class<?> shadow$_klass_;
  134. private transient int shadow$_monitor_;
  135.  
  136. // Uncomment the following two fields to enable brooks pointers.
  137. // Meant to do "#ifdef USE_BROOKS_POINTER ... #endif" but no macros.
  138. //
  139. // Note names use a 'x' prefix and the _x_rb_ptr_ field is of
  140. // type int instead of Object to go with the alphabetical/by-type
  141. // field order.
  142. // private transient int shadow$_x_rb_ptr_;
  143. // private transient int shadow$_x_xpadding_;
  144.  
  145. /**
  146. * Constructs a new instance of {@code Object}.
  147. */
  148. public Object() {
  149. }
  150.  
  151. /**
  152. * Creates and returns a copy of this {@code Object}. The default
  153. * implementation returns a so-called "shallow" copy: It creates a new
  154. * instance of the same class and then copies the field values (including
  155. * object references) from this instance to the new instance. A "deep" copy,
  156. * in contrast, would also recursively clone nested objects. A subclass that
  157. * needs to implement this kind of cloning should call {@code super.clone()}
  158. * to create the new instance and then create deep copies of the nested,
  159. * mutable objects.
  160. *
  161. * @return a copy of this object.
  162. * @throws CloneNotSupportedException
  163. * if this object's class does not implement the {@code
  164. * Cloneable} interface.
  165. */
  166. protected Object clone() throws CloneNotSupportedException {
  167. if (!(this instanceof Cloneable)) {
  168. throw new CloneNotSupportedException("Class " + getClass().getName() +
  169. " doesn't implement Cloneable");
  170. }
  171.  
  172. return internalClone();
  173. }
  174.  
  175. /*
  176. * Native helper method for cloning.
  177. */
  178. private native Object internalClone();
  179.  
  180. /**
  181. * Compares this instance with the specified object and indicates if they
  182. * are equal. In order to be equal, {@code o} must represent the same object
  183. * as this instance using a class-specific comparison. The general contract
  184. * is that this comparison should be reflexive, symmetric, and transitive.
  185. * Also, no object reference other than null is equal to null.
  186. *
  187. * <p>The default implementation returns {@code true} only if {@code this ==
  188. * o}. See <a href="{@docRoot}reference/java/lang/Object.html#writing_equals">Writing a correct
  189. * {@code equals} method</a>
  190. * if you intend implementing your own {@code equals} method.
  191. *
  192. * <p>The general contract for the {@code equals} and {@link
  193. * #hashCode()} methods is that if {@code equals} returns {@code true} for
  194. * any two objects, then {@code hashCode()} must return the same value for
  195. * these objects. This means that subclasses of {@code Object} usually
  196. * override either both methods or neither of them.
  197. *
  198. * @param o
  199. * the object to compare this instance with.
  200. * @return {@code true} if the specified object is equal to this {@code
  201. * Object}; {@code false} otherwise.
  202. * @see #hashCode
  203. */
  204. public boolean equals(Object o) {
  205. return this == o;
  206. }
  207.  
  208. /**
  209. * Invoked when the garbage collector has detected that this instance is no longer reachable.
  210. * The default implementation does nothing, but this method can be overridden to free resources.
  211. *
  212. * <p>Note that objects that override {@code finalize} are significantly more expensive than
  213. * objects that don't. Finalizers may be run a long time after the object is no longer
  214. * reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup.
  215. * Note also that finalizers are run on a single VM-wide finalizer thread,
  216. * so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary
  217. * for a class that has a native peer and needs to call a native method to destroy that peer.
  218. * Even then, it's better to provide an explicit {@code close} method (and implement
  219. * {@link java.io.Closeable}), and insist that callers manually dispose of instances. This
  220. * works well for something like files, but less well for something like a {@code BigInteger}
  221. * where typical calling code would have to deal with lots of temporaries. Unfortunately,
  222. * code that creates lots of temporaries is the worst kind of code from the point of view of
  223. * the single finalizer thread.
  224. *
  225. * <p>If you <i>must</i> use finalizers, consider at least providing your own
  226. * {@link java.lang.ref.ReferenceQueue} and having your own thread process that queue.
  227. *
  228. * <p>Unlike constructors, finalizers are not automatically chained. You are responsible for
  229. * calling {@code super.finalize()} yourself.
  230. *
  231. * <p>Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer
  232. * thread.
  233. *
  234. * See <i>Effective Java</i> Item 7, "Avoid finalizers" for more.
  235. */
  236. @FindBugsSuppressWarnings("FI_EMPTY")
  237. protected void finalize() throws Throwable {
  238. }
  239.  
  240. /**
  241. * Returns the unique instance of {@link Class} that represents this
  242. * object's class. Note that {@code getClass()} is a special case in that it
  243. * actually returns {@code Class<? extends Foo>} where {@code Foo} is the
  244. * erasure of the type of the expression {@code getClass()} was called upon.
  245. * <p>
  246. * As an example, the following code actually compiles, although one might
  247. * think it shouldn't:
  248. * <p>
  249. * <pre>{@code
  250. * List<Integer> l = new ArrayList<Integer>();
  251. * Class<? extends List> c = l.getClass();}</pre>
  252. *
  253. * @return this object's {@code Class} instance.
  254. */
  255. public final Class<?> getClass() {
  256. return shadow$_klass_;
  257. }
  258.  
  259. /**
  260. * Returns an integer hash code for this object. By contract, any two
  261. * objects for which {@link #equals} returns {@code true} must return
  262. * the same hash code value. This means that subclasses of {@code Object}
  263. * usually override both methods or neither method.
  264. *
  265. * <p>Note that hash values must not change over time unless information used in equals
  266. * comparisons also changes.
  267. *
  268. * <p>See <a href="{@docRoot}reference/java/lang/Object.html#writing_hashCode">Writing a correct
  269. * {@code hashCode} method</a>
  270. * if you intend implementing your own {@code hashCode} method.
  271. *
  272. * @return this object's hash code.
  273. * @see #equals
  274. */
  275. public int hashCode() {
  276. int lockWord = shadow$_monitor_;
  277. final int lockWordMask = 0xC0000000; // Top 2 bits.
  278. final int lockWordStateHash = 0x80000000; // Top 2 bits are value 2 (kStateHash).
  279. if ((lockWord & lockWordMask) == lockWordStateHash) {
  280. return lockWord & ~lockWordMask;
  281. }
  282. return System.identityHashCode(this);
  283. }
  284.  
  285. /**
  286. * Causes a thread which is waiting on this object's monitor (by means of
  287. * calling one of the {@code wait()} methods) to be woken up. If more than
  288. * one thread is waiting, one of them is chosen at the discretion of the
  289. * VM. The chosen thread will not run immediately. The thread
  290. * that called {@code notify()} has to release the object's monitor first.
  291. * Also, the chosen thread still has to compete against other threads that
  292. * try to synchronize on the same object.
  293. *
  294. * <p>This method can only be invoked by a thread which owns this object's
  295. * monitor. A thread becomes owner of an object's monitor
  296. * <ul>
  297. * <li>by executing a synchronized method of that object;</li>
  298. * <li>by executing the body of a {@code synchronized} statement that
  299. * synchronizes on the object;</li>
  300. * <li>by executing a synchronized static method if the object is of type
  301. * {@code Class}.</li>
  302. * </ul>
  303. *
  304. * @see #notifyAll
  305. * @see #wait()
  306. * @see #wait(long)
  307. * @see #wait(long,int)
  308. * @see java.lang.Thread
  309. */
  310. public final native void notify();
  311.  
  312. /**
  313. * Causes all threads which are waiting on this object's monitor (by means
  314. * of calling one of the {@code wait()} methods) to be woken up. The threads
  315. * will not run immediately. The thread that called {@code notify()} has to
  316. * release the object's monitor first. Also, the threads still have to
  317. * compete against other threads that try to synchronize on the same object.
  318. *
  319. * <p>This method can only be invoked by a thread which owns this object's
  320. * monitor. A thread becomes owner of an object's monitor
  321. * <ul>
  322. * <li>by executing a synchronized method of that object;</li>
  323. * <li>by executing the body of a {@code synchronized} statement that
  324. * synchronizes on the object;</li>
  325. * <li>by executing a synchronized static method if the object is of type
  326. * {@code Class}.</li>
  327. * </ul>
  328. *
  329. * @throws IllegalMonitorStateException
  330. * if the thread calling this method is not the owner of this
  331. * object's monitor.
  332. * @see #notify
  333. * @see #wait()
  334. * @see #wait(long)
  335. * @see #wait(long,int)
  336. * @see java.lang.Thread
  337. */
  338. public final native void notifyAll();
  339.  
  340. /**
  341. * Returns a string containing a concise, human-readable description of this
  342. * object. Subclasses are encouraged to override this method and provide an
  343. * implementation that takes into account the object's type and data. The
  344. * default implementation is equivalent to the following expression:
  345. * <pre>
  346. * getClass().getName() + '@' + Integer.toHexString(hashCode())</pre>
  347. * <p>See <a href="{@docRoot}reference/java/lang/Object.html#writing_toString">Writing a useful
  348. * {@code toString} method</a>
  349. * if you intend implementing your own {@code toString} method.
  350. *
  351. * @return a printable representation of this object.
  352. */
  353. public String toString() {
  354. return getClass().getName() + '@' + Integer.toHexString(hashCode());
  355. }
  356.  
  357. /**
  358. * Causes the calling thread to wait until another thread calls the {@code
  359. * notify()} or {@code notifyAll()} method of this object. This method can
  360. * only be invoked by a thread which owns this object's monitor; see
  361. * {@link #notify()} on how a thread can become the owner of a monitor.
  362. *
  363. * <p>A waiting thread can be sent {@code interrupt()} to cause it to
  364. * prematurely stop waiting, so {@code wait} should be called in a loop to
  365. * check that the condition that has been waited for has been met before
  366. * continuing.
  367. *
  368. * <p>While the thread waits, it gives up ownership of this object's
  369. * monitor. When it is notified (or interrupted), it re-acquires the monitor
  370. * before it starts running.
  371. *
  372. * @throws IllegalMonitorStateException
  373. * if the thread calling this method is not the owner of this
  374. * object's monitor.
  375. * @throws InterruptedException if the current thread has been interrupted.
  376. * The interrupted status of the current thread will be cleared before the exception
  377. * is thrown.
  378. * @see #notify
  379. * @see #notifyAll
  380. * @see #wait(long)
  381. * @see #wait(long,int)
  382. * @see java.lang.Thread
  383. */
  384. public final native void wait() throws InterruptedException;
  385.  
  386. /**
  387. * Causes the calling thread to wait until another thread calls the {@code
  388. * notify()} or {@code notifyAll()} method of this object or until the
  389. * specified timeout expires. This method can only be invoked by a thread
  390. * which owns this object's monitor; see {@link #notify()} on how a thread
  391. * can become the owner of a monitor.
  392. *
  393. * <p>A waiting thread can be sent {@code interrupt()} to cause it to
  394. * prematurely stop waiting, so {@code wait} should be called in a loop to
  395. * check that the condition that has been waited for has been met before
  396. * continuing.
  397. *
  398. * <p>While the thread waits, it gives up ownership of this object's
  399. * monitor. When it is notified (or interrupted), it re-acquires the monitor
  400. * before it starts running.
  401. *
  402. * <p>A timeout of zero means the calling thread should wait forever unless interrupted or
  403. * notified.
  404. *
  405. * @param millis
  406. * the maximum time to wait in milliseconds.
  407. * @throws IllegalArgumentException
  408. * if {@code millis < 0}.
  409. * @throws IllegalMonitorStateException
  410. * if the thread calling this method is not the owner of this
  411. * object's monitor.
  412. * @throws InterruptedException if the current thread has been interrupted.
  413. * The interrupted status of the current thread will be cleared before the exception
  414. * is thrown.
  415. * @see #notify
  416. * @see #notifyAll
  417. * @see #wait()
  418. * @see #wait(long,int)
  419. * @see java.lang.Thread
  420. */
  421. public final void wait(long millis) throws InterruptedException {
  422. wait(millis, 0);
  423. }
  424.  
  425. /**
  426. * Causes the calling thread to wait until another thread calls the {@code
  427. * notify()} or {@code notifyAll()} method of this object or until the
  428. * specified timeout expires. This method can only be invoked by a thread
  429. * that owns this object's monitor; see {@link #notify()} on how a thread
  430. * can become the owner of a monitor.
  431. *
  432. * <p>A waiting thread can be sent {@code interrupt()} to cause it to
  433. * prematurely stop waiting, so {@code wait} should be called in a loop to
  434. * check that the condition that has been waited for has been met before
  435. * continuing.
  436. *
  437. * <p>While the thread waits, it gives up ownership of this object's
  438. * monitor. When it is notified (or interrupted), it re-acquires the monitor
  439. * before it starts running.
  440. *
  441. * <p>A timeout of zero means the calling thread should wait forever unless interrupted or
  442. * notified.
  443. *
  444. * @param millis
  445. * the maximum time to wait in milliseconds.
  446. * @param nanos
  447. * the fraction of a millisecond to wait, specified in
  448. * nanoseconds.
  449. * @throws IllegalArgumentException
  450. * if {@code millis < 0}, {@code nanos < 0} or {@code nanos >
  451. * 999999}.
  452. * @throws IllegalMonitorStateException
  453. * if the thread calling this method is not the owner of this
  454. * object's monitor.
  455. * @throws InterruptedException if the current thread has been interrupted.
  456. * The interrupted status of the current thread will be cleared before the exception
  457. * is thrown.
  458. * @see #notify
  459. * @see #notifyAll
  460. * @see #wait()
  461. * @see #wait(long,int)
  462. * @see java.lang.Thread
  463. */
  464. public final native void wait(long millis, int nanos) throws InterruptedException;
  465. }

Java的Object对象的更多相关文章

  1. Java:Object对象小记

    Java:Object对象小记 对 Java 中的 Object 对象,做一个微不足道的小小小小记 Object 的常用方法有哪些 clone() 方法:用于创建并返回当前对象的一份拷贝: 在Java ...

  2. 【java基础】java中Object对象中的Hashcode方法的作用

    以下是关于HashCode的官方文档定义: hashcode方法返回该对象的哈希码值.支持该方法是为哈希表提供一些优点,例如,java.util.Hashtable 提供的哈希表. hashCode  ...

  3. Java之Object对象中的wait()和notifyAll()用法

    用一个例子来说明Object对象中的wait方法和notifyAll方法的使用. 首先定义一个消息类,用于封装数据,以供读写线程进行操作: /** * 消息 * * @author syj */ pu ...

  4. JAVA将Object对象转byte数组

    /** * 将Object对象转byte数组 * @param obj byte数组的object对象 * @return */ public static byte[] toByteArray(Ob ...

  5. Java Object 对象创建的方式 [ 转载 ]

    Java Object 对象创建的方式 [ 转载 ] @author http://blog.csdn.net/mhmyqn/article/details/7943411 显式创建 有4种显式地创建 ...

  6. Java Object 对象拷贝答疑

    Java Object 对象拷贝答疑 @author ixenos 摘要:在对象的clone过程需要注意的几点.关于关键字this.super 关于clone[对象拷贝] 在实际编程过程,有时候我们会 ...

  7. Java Object 对象拷贝

    Java Object 对象拷贝 @author ixenos JAVA 对象拷贝 Java里的clone分为:  1.浅拷贝:浅复制仅仅复制所考虑的对象,而不复制它所引用的对象,Object类里的c ...

  8. Java的Object.hashCode()的返回值到底是不是对象内存地址?

    关于这个问题,查阅了网上的资料,发现证明过程太繁琐,这里我用了反证法. java.lang.Object.hashCode()的返回值到底是不是对象内存地址? hashCode契约 说到这个问题,大家 ...

  9. java语言中Object对象的hashCode()取值的底层算法是怎样实现的

    Java语言中,Object对象有个特殊的方法:hashcode(), hashcode()表示的是JVM虚拟机为这个Object对象分配的一个int类型的数值,JVM会使用对象的hashcode值来 ...

随机推荐

  1. SQL从入门到基础–08 Union、Union all及案例

    一.联合结果集 1. 简单的结果集联合: Select FNumber,FName,FAge from T_Employee union select FidCardNumber,FName,FAge ...

  2. zeromq源码分析笔记之架构(1)

    1.zmq概述 ZeroMQ是一种基于消息队列的多线程网络库,其对套接字类型.连接处理.帧.甚至路由的底层细节进行抽象,提供跨越多种传输协议的套接字.引用云风的话来说:ZeroMQ 并不是一个对 so ...

  3. JDK + Tomcat 安装配置

    学习Java 开发的第一步就是配置环境,今天第一次配置,把过程记录下以备后用. 一.下载JDK.Tomcat JDK:http://www.oracle.com/technetwork/java/ja ...

  4. Python学习笔记整理(五)Python中的列表.

    列表和字段,这两种类型几乎是Python所有脚本的主要工作组件.他们都可以在原处进行修改,可以按需求增加或缩短,而且包含任何种类的对象或者被嵌套. 一.列表 列表的主要属性: *任意对象的有序集合 从 ...

  5. Python学习笔记总结(四)异常处理

    1.基础 try/except/else:[else是可选的]捕捉由代码中的异常并恢复,匹配except里面的错误,并执行except中定义的代码,后继续执行程序(发生异常后,由except捕捉到异常 ...

  6. fgets和scanf的区别

    fgets和scanf的区别 1.测试使用scanf的一个例子: #include "stdio.h" #include "string.h" int main ...

  7. Android学习笔记--获取传感器信息

    相关资料: 传感器的坐标与读数:http://www.cnblogs.com/mengdd/archive/2013/05/19/3086781.html 传感器介绍及指南针原理:http://www ...

  8. CCI_chapter 16 Low level

    16.5 Write a program to find whether a machine is big endian or little endian Big-Endian和Little-Endi ...

  9. Qt error:QtThese QT version are inaccessible

    安装完Qt Add-in 打开VS2013的时候出现标题错误. QTDIR 需要设置成Qt安装目录下的vc,这个vc目录下包含include,lib,bin等文件夹.或者是在Qt Option里面设置 ...

  10. sqlplus与sqlplusw (转)

    一.sqlplus与sqlplusw两者统称SQLPlus,是Oracle的一个命令行执行工具.   二.SQLPlus的有两种运行方式: 1.在命令行窗口运行.sqlplus 2.在窗口中运行.sq ...