学习笔记之Java
All contents are moved to haoran119/java (github.com).
Java (programming language) - Wikipedia
- https://en.wikipedia.org/wiki/Java_(programming_language)
- Java is a general-purpose computer-programming language that is concurrent, class-based, object-oriented,[15] and specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA),[16] meaning that compiled Java code can run on all platforms that support Java without the need for recompilation.[17] Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture. As of 2016, Java is one of the most popular programming languages in use,[18][19][20][21] particularly for client-server web applications, with a reported 9 million developers.[22] Java was originally developed by James Gosling at Sun Microsystems (which has since been acquired by Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its original features from SmallTalk, with a syntax similar to C and C++, but it has fewer low-levelfacilities than either of them.
- The original and reference implementation Java compilers, virtual machines, and class libraries were originally released by Sun under proprietary licenses. As of May 2007, in compliance with the specifications of the Java Community Process, Sun relicensed most of its Java technologies under the GNU General Public License. Others have also developed alternative implementations of these Sun technologies, such as the GNU Compiler for Java (bytecode compiler), GNU Classpath (standard libraries), and IcedTea-Web (browser plugin for applets).
- The latest version is Java 11, released on September 25, 2018. Java 11 is a currently supported long-term support (LTS) version ("Oracle Customers will receive Oracle Premier Support"); Oracle released for the "legacy" Java 8 LTS the last "public update", which is free for commercial use, in January 2019. Oracle will still support Java 8 with public updates for personal use up to at least December 2020. Oracle (and others) "highly recommend that you uninstall older versions of Java",[23] because of serious risks due to unresolved security issues.[24][25][26] Since Java 9 is no longer supported, Oracle advises its users to "immediately transition" to Java 11. Oracle extended support for Java 6 ended in December 2018.[27]
面试总结之JAVA - 浩然119 - 博客园 (cnblogs.com)
学习笔记之Java程序设计实用教程 - 浩然119 - 博客园 (cnblogs.com)
学习笔记之JAVA多线程 - 浩然119 - 博客园 (cnblogs.com)
一文详解 Java 的八大基本类型!
- https://mp.weixin.qq.com/s/0fvEX2c9XLYy4A9IOQ69TA
- https://dev.to/renegadecoder94/the-8-primitive-types-in-java-10cl
【Java基础内容总结】Java基础看这个就足够了
- https://mp.weixin.qq.com/s/JvACACqDAxxhJ18cjV-M8w
- https://blog.csdn.net/harry_c/article/details/103108304
自己动手一个HashMap
如何检查 Java 数组中是否包含某个值 ?
终于明白为什么要加 final 关键字了!
字符串拼接还在用StringBuilder?快试试Java8中的StringJoiner吧,真香! (qq.com)
从String中移除空白字符的多种方式!?差别竟然这么大! (qq.com)
在Java中如何优雅地判空
是否注意过isEmpty 和 isBlank 区别?
为什么阿里巴巴禁止在 foreach 循环里进行元素的 remove/add 操作 - Java编程
为什么建议使用你 LocalDateTime ,而不是 Date?
YYYY-MM-dd 的Bug
Java 8:一文掌握 Lambda 表达式 | CSDN 博文精选
Java泛型背后的秘密
Java程序员必备:异常的十个关键知识点
Java 异常处理的 20 个最佳实践,你知道几个?| CSDN 博文精选
多线程
线程最最基础的知识
线程池学习总结
为什么 Java 进程使用的 RAM 比 Heap Size 大? | CSDN博文精选
- https://mp.weixin.qq.com/s/SDSN8QLQjZVw4zNrRdR99w
- https://blog.csdn.net/duqi_2009/article/details/101158407
死磕 java线程——自己动手写一个线程池
很遗憾,没有一篇文章能讲清楚线程的生命周期!
如何线程安全地遍历List
IO通信模型—同步阻塞模式BIO
Java多线程优化
一文足以了解什么是 Java 中的锁
volatile和synchronized到底啥区别?多图文讲解告诉你 (qq.com)
SimpleDateFormat线程不安全的5种解决方案! (qq.com)
BEST PRACTICE
熬了 3 天夜,小吴肝出了万字 Java 知识地图手册! (qq.com)
Java 那些最常用的工具类库 | 原力计划
写了那么多年 Java 代码,终于 debug 到 JVM 了
java虚拟机内存模型
- https://mp.weixin.qq.com/s/m2dp6jv8lfmy-S2gmQDHvA
- https://blog.csdn.net/qq_37141773/article/details/103138476#comments
大白话带你认识JVM
JVM核心知识体系
看完这篇垃圾回收,和面试官扯皮没问题了
JDK源码中,都有哪些NB的设计模式?
- https://mp.weixin.qq.com/s/4_BF2RROlIRrZm_sNzpSWQ
- https://www.javacodegeeks.com/2011/03/design-patterns-in-jdk.html
一份阿里员工排查Java问题的命令列表
Java 语言中十大“坑爹”功能!
从 0 开始手写一个 Mybatis 框架,三步搞定!
Q & A
How to halt the program ?
- System.exit(1);
How to convert double to long ?
- How to Convert a Double to Long in Java - Example Tutorial | Java67
- Double.longValue()
- casting a double to long
- if you need rounding you can use Math.round() method to round a floating point number into nearest integral number
1 public class DoubleToLong { 2 3 4 public static void main(String args[]){ 5 6 // first example - converting double to long using longValue() method 7 double d = 102.9520; 8 long l = (new Double(d)).longValue(); 9 System.out.println("double value=" + d + ", long=" + l); 10 11 // second example - rather simple just cast double to long 12 double bill = 293.05; 13 long myBill = (long) bill; 14 System.out.println("double value=" + bill + ", long=" + myBill); 15 16 17 // third example - rounding double value to long in Java 18 double dbl = 3421.56; 19 long rnd = Math.round(dbl); 20 System.out.println("double value=" + dbl + ", long=" + rnd); 21 22 } 23 24 } 25 26 Output 27 double value=102.952, long=102 28 double value=293.05, long=293 29 double value=3421.56, long=3422 30 31 32 Read more: https://www.java67.com/2014/11/how-to-convert-double-to-long-in-java-example.html#ixzz6vAnV7wT7
How to convert long to string ?
- Java Program to Convert Long to String - GeeksforGeeks
- String str = Long.toString(varLong);
How to compare string ?
- How do I compare strings in Java? - Stack Overflow
==
tests for reference equality (whether they are the same object)..equals()
tests for value equality (whether they are logically "equal").
How to check if double is 0 ?
What's the Java equivant of Python List ?
- ArrayList<>
- The List Interface (The Java™ Tutorials > Collections > Interfaces) (oracle.com)
- A
List
is an orderedCollection
(sometimes called a sequence). Lists may contain duplicate elements. In addition to the operations inherited fromCollection
, theList
interface includes operations for the following:Positional access
— manipulates elements based on their numerical position in the list. This includes methods such asget
,set
,add
,addAll
, andremove
.Search
— searches for a specified object in the list and returns its numerical position. Search methods includeindexOf
andlastIndexOf
.Iteration
— extendsIterator
semantics to take advantage of the list's sequential nature. ThelistIterator
methods provide this behavior.Range-view
— Thesublist
method performs arbitrary range operations on the list.
- A
- Java equivalent of Python List - Stack Overflow
- ArrayList in Java - GeeksforGeeks
- Java.util.ArrayList.addall() method in Java - GeeksforGeeks
- ArrayList removeIf() method in Java - GeeksforGeeks
- ArrayList get(index) method in Java with examples - GeeksforGeeks
- Arraylist.contains() in Java - GeeksforGeeks
- Collections.sort() in Java with Examples - GeeksforGeeks
What's LinkedHashMap ?
- LinkedHashMap (Java Platform SE 8 ) (oracle.com)
- LinkedHashMap in Java - GeeksforGeeks
- HashMap keySet() Method in Java - GeeksforGeeks
- Map Interface in Java - GeeksforGeeks
- Stream flatMap() in Java with examples - GeeksforGeeks
- Iterable (Java SE 11 & JDK 11 ) (oracle.com)
- Iterable Interface in Java - GeeksforGeeks
What's LinkedHashSet and HashSet ?
- LinkedHashSet in Java with Examples - GeeksforGeeks
- Convert LinkedHashSet to ArrayList in Java Example - Java Code Examples
- AbstractCollection toArray() Method in Java with Examples - GeeksforGeeks
- AbstractCollection addAll() Method in Java with Examples - GeeksforGeeks
- HashSet in Java - GeeksforGeeks
What's Stream ?
- Stream In Java - GeeksforGeeks
- Stream map() in Java with examples - GeeksforGeeks
- How to Convert List to Map in Java | Baeldung
- Examples of Converting List to Map using Streams | amitph
How to get fields with Java reflection ?
- Class (Java SE 10 & JDK 10 ) (oracle.com)
- public Field[] getFields() throws SecurityException
- Returns an array containing
Field
objects reflecting all the accessible public fields of the class or interface represented by thisClass
object. - If this
Class
object represents a class or interface with no accessible public fields, then this method returns an array of length 0. - If this
Class
object represents a class, then this method returns the public fields of the class and of all its superclasses and superinterfaces. - If this
Class
object represents an interface, then this method returns the fields of the interface and of all its superinterfaces. - If this
Class
object represents an array type, a primitive type, or void, then this method returns an array of length 0. - The elements in the returned array are not sorted and are not in any particular order.
- Returns:
- the array of
Field
objects representing the public fields
- the array of
- Class (Java SE 10 & JDK 10 ) (oracle.com)
- public Field[] getDeclaredFields() throws SecurityException
- Returns an array of
Field
objects reflecting all the fields declared by the class or interface represented by thisClass
object. This includes public, protected, default (package) access, and private fields, but excludes inherited fields. - If this
Class
object represents a class or interface with no declared fields, then this method returns an array of length 0. - If this
Class
object represents an array type, a primitive type, or void, then this method returns an array of length 0. - The elements in the returned array are not sorted and are not in any particular order.
- Returns:
- the array of
Field
objects representing all the declared fields of this class
- the array of
- Java.lang.Class.getField() Method - Tutorialspoint
- Java.lang.Class.getDeclaredFields() Method - Tutorialspoint
- To access private fields, need to set accessible with Method (Java SE 11 & JDK 11 ) (oracle.com)
- public void setAccessible(boolean flag)
-
Description copied from class:
AccessibleObject
-
Set the
accessible
flag for this reflected object to the indicated boolean value. A value oftrue
indicates that the reflected object should suppress checks for Java language access control when it is used. A value offalse
indicates that the reflected object should enforce checks for Java language access control when it is used, with the variation noted in the class description. - This method may be used by a caller in class
C
to enable access to amember
ofdeclaring class
D
if any of the following hold:C
andD
are in the same module.- The member is
public
andD
ispublic
in a package that the module containingD
exports
to at least the module containingC
. - The member is
protected
static
,D
ispublic
in a package that the module containingD
exports to at least the module containingC
, andC
is a subclass ofD
. D
is in a package that the module containingD
opens
to at least the module containingC
. All packages in unnamed and open modules are open to all modules and so this method always succeeds whenD
is in an unnamed or open module.
- This method cannot be used to enable access to private members, members with default (package) access, protected instance members, or protected constructors when the declaring class is in a different module to the caller and the package containing the declaring class is not open to the caller's module.
- If there is a security manager, its
checkPermission
method is first called with aReflectPermission("suppressAccessChecks")
permission.
- What is the difference between getFields and getDeclaredFields in Java reflection - Stack Overflow
- getFields()
- All the
public
fields up the entire class hierarchy.
- All the
- getDeclaredFields()
- All the fields, regardless of their accessibility but only for the current class, not any base classes that the current class might be inheriting from.
- getFields()