-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.xml
90 lines (42 loc) · 63.5 KB
/
search.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?xml version="1.0" encoding="utf-8"?>
<search>
<entry>
<title>Angular</title>
<link href="/2022/07/29/Angular/"/>
<url>/2022/07/29/Angular/</url>
<content type="html"><![CDATA[]]></content>
<categories>
<category> angular </category>
</categories>
</entry>
<entry>
<title>JavaSE基础知识点</title>
<link href="/2022/07/29/JavaSE/"/>
<url>/2022/07/29/JavaSE/</url>
<content type="html"><![CDATA[<h1 id="JAVA知识点"><a href="#JAVA知识点" class="headerlink" title="JAVA知识点"></a>JAVA知识点</h1><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Hello</span>(){</span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span>{</span><br><span class="line"> System.println(<span class="string">"Hello World"</span>);</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h2 id="java语言有哪些特点"><a href="#java语言有哪些特点" class="headerlink" title="java语言有哪些特点"></a>java语言有哪些特点</h2><p>封装、继承、多态、反射机制、集合、泛型</p><h3 id="Java面向对象基础"><a href="#Java面向对象基础" class="headerlink" title="Java面向对象基础"></a>Java面向对象基础</h3><h5 id="面向对象与面向过程的区别?"><a href="#面向对象与面向过程的区别?" class="headerlink" title="面向对象与面向过程的区别?"></a>面向对象与面向过程的区别?</h5><p>面向对象的特点:易维护,易扩展,易复用。</p><p>面向对象实际上是面向抽象编程,解决问题时会先抽象出对象,再使用对象执行方法来解决。</p><p>面向过程会把解决问题的过程拆分出一个个方法,使用方法来解决问题。</p><h5 id="面向对象的三大特征"><a href="#面向对象的三大特征" class="headerlink" title="面向对象的三大特征"></a>面向对象的三大特征</h5><p>封装继承和多态</p><p><strong>封装:</strong></p><p>封装是指把一个对象的状态信息(也就是属性)隐藏在对象内部,不允许外部对象直接访问对象的内部信息。但是可以提供一些可以被外界访问的方法来操作属性。</p><p><strong>继承:</strong></p><p><strong>多态:</strong></p><hr><h4 id="为什么说-Java-语言“编译与解释并存”?"><a href="#为什么说-Java-语言“编译与解释并存”?" class="headerlink" title="为什么说 Java 语言“编译与解释并存”?"></a>为什么说 Java 语言“编译与解释并存”?</h4><p>首先我们要区分什么是编译型语言,什么是解释性语言</p><p><strong>编译型语言:</strong></p><p>编译型语言会通过<strong>编译器</strong>将源代码一次性翻译成<strong>可被该平台执行的机器码</strong>。一般情况下,编译语言的<strong>执行速度比较快,开发效率比较低</strong>。常见的编译性语言有 C、C++、Go、Rust 等等。</p><p><strong>解释型语言:</strong></p><p>解释型语言会通过<strong>解释器</strong>一句一句的将代码<strong>解释(interpret)为机器代码</strong>后再执行。解释型语言<strong>开发效率比较快,执行速度比较慢</strong>。常见的解释性语言有 Python、JavaScript、PHP 等等。</p><p>因为 Java 语言既具有编译型语言的特征,也具有解释型语言的特征。因为 Java 程序要经过先编译,后解释两个步骤,由 Java 编写的程序需要先经过编译步骤,生成字节码(<code>.class</code> 文件),这种字节码必须由 Java 解释器来解释执行。</p><h4 id="标识符与关键字的区别"><a href="#标识符与关键字的区别" class="headerlink" title="标识符与关键字的区别"></a>标识符与关键字的区别</h4><p><strong>我们常用的方法、类、变量、程序的名字就是标识符。</strong></p><p><strong>可以认为关键字是在java中赋予特殊意义的标识符。</strong></p><blockquote><p>虽然 <code>true</code>, <code>false</code>, 和 <code>null</code> 看起来像关键字但实际上他们是字面值,同时你也不可以作为标识符来使用。</p></blockquote><h4 id="字符型常量和字符串常量的区别"><a href="#字符型常量和字符串常量的区别" class="headerlink" title="字符型常量和字符串常量的区别?"></a>字符型常量和字符串常量的区别?</h4><ol><li><strong>形式</strong> : 字符常量是单引号引起的一个字符,字符串常量是双引号引起的 0 个或若干个字符。</li><li><strong>含义</strong> : 字符常量相当于一个整型值( ASCII 值),可以参加表达式运算; 字符串常量代表一个地址值(该字符串在内存中存放位置)。</li><li><strong>占内存大小</strong> : 字符常量只占 2 个字节; 字符串常量占若干个字节。</li></ol><blockquote><p>char 在Java中占据两个字符。</p></blockquote><h2 id="HashMap集合遍历的七种方式"><a href="#HashMap集合遍历的七种方式" class="headerlink" title="HashMap集合遍历的七种方式"></a>HashMap集合遍历的七种方式</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * HashMap集合遍历的七种方式</span></span><br><span class="line"><span class="comment"> * 总结:</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span> Ryuzu</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@date</span> 2021/11/21 19:19</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">HashMapTest</span> {</span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"> Map<Integer,String> map = <span class="keyword">new</span> <span class="title class_">HashMap</span>();</span><br><span class="line"> map.put(<span class="number">1</span>, <span class="string">"java"</span>);</span><br><span class="line"> map.put(<span class="number">2</span>, <span class="string">"javaSE"</span>);</span><br><span class="line"> map.put(<span class="number">3</span>, <span class="string">"javaEE"</span>);</span><br><span class="line"> map.put(<span class="number">4</span>, <span class="string">"Spring"</span>);</span><br><span class="line"> map.put(<span class="number">5</span>, <span class="string">"SpringMVC"</span>);</span><br><span class="line"> map.put(<span class="number">6</span>, <span class="string">"MyBatis"</span>);</span><br><span class="line"></span><br><span class="line"> way1(map);</span><br><span class="line"> way2(map);</span><br><span class="line"> way3(map);</span><br><span class="line"> way4(map);</span><br><span class="line"> way5(map);</span><br><span class="line"> way6(map);</span><br><span class="line"> way7(map);</span><br><span class="line"></span><br><span class="line"> System.out.println(Integer.valueOf(<span class="string">'\t'</span>));<span class="comment">//9</span></span><br><span class="line"></span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="comment">/*</span></span><br><span class="line"><span class="comment"> 迭代器EntrySet</span></span><br><span class="line"><span class="comment"> 遍历方式</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">way1</span><span class="params">(Map<Integer,String > map)</span> {</span><br><span class="line"> Iterator<Map.Entry<Integer,String>> it = map.entrySet().iterator();</span><br><span class="line"> <span class="keyword">while</span> (it.hasNext()) {</span><br><span class="line"> Map.Entry<Integer,String> node = it.next();</span><br><span class="line"> System.out.println(node.getKey() + <span class="string">"\t"</span> + node.getValue());</span><br><span class="line"> }</span><br><span class="line"> System.out.println();</span><br><span class="line"> }</span><br><span class="line"> <span class="comment">/*</span></span><br><span class="line"><span class="comment"> ForEach EntrySet</span></span><br><span class="line"><span class="comment"> 遍历</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">way2</span><span class="params">(Map<Integer,String> map)</span>{</span><br><span class="line"> Set<Map.Entry<Integer,String>> set = map.entrySet();</span><br><span class="line"> <span class="keyword">for</span> (Map.Entry<Integer, String> entry : set) {</span><br><span class="line"> System.out.println(entry.getKey() + <span class="string">"\t"</span> + entry.getValue());</span><br><span class="line"> }</span><br><span class="line"> System.out.println();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="comment">/*</span></span><br><span class="line"><span class="comment"> 迭代器 KeySet</span></span><br><span class="line"><span class="comment"> 遍历</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">way3</span><span class="params">(Map<Integer, String> map)</span>{</span><br><span class="line"> Set<Integer> set = map.keySet();</span><br><span class="line"> Iterator<Integer> it = set.iterator();</span><br><span class="line"> <span class="keyword">while</span> (it.hasNext()) {</span><br><span class="line"> <span class="type">int</span> <span class="variable">key</span> <span class="operator">=</span> it.next();</span><br><span class="line"> System.out.println(key + <span class="string">"\t"</span> + map.get(key));</span><br><span class="line"> }</span><br><span class="line"> System.out.println();</span><br><span class="line"></span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="comment">/*</span></span><br><span class="line"><span class="comment"> ForEach KeySet</span></span><br><span class="line"><span class="comment"> 遍历方式</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">way4</span><span class="params">(Map<Integer, String> map)</span>{</span><br><span class="line"> Set<Integer> set = map.keySet();</span><br><span class="line"> <span class="keyword">for</span> (Integer integer : set) {</span><br><span class="line"> System.out.println(integer + <span class="string">"\t"</span> + map.get(integer));</span><br><span class="line"> }</span><br><span class="line"> System.out.println();</span><br><span class="line"></span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="comment">/*</span></span><br><span class="line"><span class="comment"> Lambda函数</span></span><br><span class="line"><span class="comment"> 遍历</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">way5</span><span class="params">(Map<Integer, String> map)</span> {</span><br><span class="line"> map.forEach((key,value)-></span><br><span class="line"> System.out.println(key + <span class="string">"\t"</span> + value)</span><br><span class="line"> );</span><br><span class="line"></span><br><span class="line"> System.out.println();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="comment">/*</span></span><br><span class="line"><span class="comment"> Stream API 单线程</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">way6</span><span class="params">(Map<Integer, String> map)</span> {</span><br><span class="line"> map.entrySet().stream().</span><br><span class="line"> forEach(node -> System.out.println(node.getKey() + <span class="string">"\t"</span> + node.getValue()));</span><br><span class="line"> System.out.println();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"> <span class="comment">/*</span></span><br><span class="line"><span class="comment"> Stream 多线程</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">way7</span><span class="params">(Map<Integer, String> map)</span> {</span><br><span class="line"> map.entrySet().parallelStream().</span><br><span class="line"> forEach(node -> System.out.println(node.getKey() + <span class="string">"\t"</span> + node.getValue()));</span><br><span class="line"> System.out.println();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">}</span><br></pre></td></tr></table></figure><hr><h2 id="new-Integer-123-与Integer-valueOf-123-的区别在于"><a href="#new-Integer-123-与Integer-valueOf-123-的区别在于" class="headerlink" title="new Integer(123)与Integer.valueOf(123)的区别在于?"></a>new Integer(123)与Integer.valueOf(123)的区别在于?</h2><ul><li>new Integer(123) 每次都会新建一个对象;</li><li>Integer.valueOf(123) 会使用缓存池对象, 多次调用回去得同一个对象的引用</li></ul><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">Integer</span> <span class="variable">x</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Integer</span>(<span class="number">123</span>);</span><br><span class="line"><span class="type">Integer</span> <span class="variable">y</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Integer</span>(<span class="number">123</span>);</span><br><span class="line">System.out.println(x == y); <span class="comment">// false</span></span><br><span class="line"><span class="type">Integer</span> <span class="variable">z</span> <span class="operator">=</span> Integer.valueOf(<span class="number">123</span>);</span><br><span class="line"><span class="type">Integer</span> <span class="variable">k</span> <span class="operator">=</span> Integer.valueOf(<span class="number">123</span>);</span><br><span class="line">System.out.println(z == k); <span class="comment">// true</span></span><br></pre></td></tr></table></figure><hr><h2 id="Object类"><a href="#Object类" class="headerlink" title="Object类"></a>Object类</h2><h3 id="equals-与hashCode-方法的关系"><a href="#equals-与hashCode-方法的关系" class="headerlink" title="equals()与hashCode()方法的关系"></a>equals()与hashCode()方法的关系</h3><p>java对于equals()方法和hashCode()方法是这样规定的:</p><ul><li>同一对象多次调用hashCode()方法,总是返回相同的整型值</li><li>如果a.equals(b),则一定有a.hashCode()一定等于b.hashCode().</li><li>如果!a.equals(b),则a.hashCode() 不一定等于b.hashCode(),此时如果a.hashCode()总是不等于b.hashCode(),会提高hashtables的性能.</li><li>a.hashCode() == b.hashCode()则a.equals(b)可真可假.</li><li>a.hashCode()! = b.hashCode()则a.equals(b)为假.</li></ul><h2 id="Java-lang-String类"><a href="#Java-lang-String类" class="headerlink" title="Java.lang.String类"></a>Java.lang.String类</h2><p>String类被<code>final</code>修饰了, 因此他不能被继承 (Integer等包装类也不能被继承)</p><p>在java 8 中,String类使用<code>char</code>数组存储数据</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">class</span> <span class="title class_">String</span> <span class="keyword">implements</span> <span class="title class_">java</span>.io.Serializable,Comparable<String>, CharSequence {</span><br><span class="line"><span class="comment">/** The value is used for character storage. */</span></span><br><span class="line"><span class="keyword">private</span> <span class="keyword">final</span> <span class="type">char</span> value[];</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>在java 9 之后, String类的实现该用了byte数组了存储字符串, 并且使用了<code>coder</code>来标识使用了哪个编码</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">class</span> <span class="title class_">String</span> <span class="keyword">implements</span> <span class="title class_">java</span>.io.Serializable,Comparable<String>, CharSequence {</span><br><span class="line"><span class="comment">/** The value is used for character storage. */</span></span><br><span class="line"><span class="keyword">private</span> <span class="keyword">final</span> <span class="type">byte</span>[] value;</span><br><span class="line"><span class="comment">/** The identifier of the encoding used to encode the bytes in {<span class="doctag">@code</span></span></span><br><span class="line"><span class="comment">value}. */</span></span><br><span class="line"><span class="keyword">private</span> <span class="keyword">final</span> <span class="type">byte</span> coder;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>value数组被final修饰, 这意味着value数组一旦初始化后就不可在引用其他数组, 并且String内部没有改变value数组的方法, 因此可以保证String不可变.</p><h3 id="String类型不可变的好处"><a href="#String类型不可变的好处" class="headerlink" title="String类型不可变的好处"></a>String类型不可变的好处</h3><ol><li>可以缓存hash值</li></ol><p>因为String的hash值经常被使用, 例如String用做HashMap的key, 不可变的特性也可以使得每次计算的hash值不可变, 因此只需要进行一次计算.</p><ol start="2"><li><p>String Pool 的需要</p><p>如果一个String对象已经被创建过了, 那么就会从String Pool(String的常量池)中取得引用 , 只有String是不可变的, 才可能使用String Pool</p></li><li><p>安全性</p><p>String经常作为参数, String不可变性可以保证参数不可变, 例如在作为网络连接参数的情况下如果String 是可变的, 那么在网络连接过程中, String被改变, 改变String的哪一方以为现在连接的是其他主机, 而实际情况却不一定是.</p></li><li><p>线程安全</p><p>String不可变天生具有线程安全, 可以在多个线程中安全的使用.</p></li></ol><h3 id="String-StringBuffer-和-StringBuilder"><a href="#String-StringBuffer-和-StringBuilder" class="headerlink" title="String, StringBuffer 和 StringBuilder"></a>String, StringBuffer 和 StringBuilder</h3><ol><li>可变性<ul><li>String不可变</li><li>StringBuffer 和 StringBuilder 可变</li></ul></li><li>线程安全<ul><li>String不可变, 因此是线程安全的</li><li>StringBuffer 是线程安全的, 内部使用了Synchronized锁进行同步</li><li>StringBuilder 不是线程安全的</li></ul></li></ol><h3 id="String-Pool-String-常量池"><a href="#String-Pool-String-常量池" class="headerlink" title="String Pool (String 常量池)"></a>String Pool (String 常量池)</h3><p>String Pool 保存在所有字符串字面量, 这些字面量在编译时期就确定,</p><p>不仅如此, 还可使用String的intern() 方法在运行过程中将字符串添加到String Pool中</p><h4 id="intern"><a href="#intern" class="headerlink" title="intern()"></a>intern()</h4><p>当一个字符串调用intern(0方法是, 如果String Pool 中已经存在了一个字符串和该字符串值相等(使用equals()方法) , name就很惨放回StringPool 中字符串的引用; 否则, 就会在String Pool 中添加一个新的字符串, 并返回这个字符串的引用.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">String</span> <span class="variable">s1</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">String</span>(<span class="string">"aaa"</span>);</span><br><span class="line"><span class="type">String</span> <span class="variable">s2</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">String</span>(<span class="string">"aaa"</span>);</span><br><span class="line">System.out.println(s1 == s2); <span class="comment">// false</span></span><br><span class="line"><span class="type">String</span> <span class="variable">s3</span> <span class="operator">=</span> s1.intern();</span><br><span class="line"><span class="type">String</span> <span class="variable">s4</span> <span class="operator">=</span> s2.intern();</span><br><span class="line">System.out.println(s3 == s4); <span class="comment">// true</span></span><br></pre></td></tr></table></figure><h3 id="使用String将数字位不足的地方补零"><a href="#使用String将数字位不足的地方补零" class="headerlink" title="使用String将数字位不足的地方补零"></a>使用String将数字位不足的地方补零</h3><h4 id="自定义封装"><a href="#自定义封装" class="headerlink" title="自定义封装"></a>自定义封装</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 数字不足位数前后补0</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> num 参与补零的数字</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> len 最终位数长度</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> prev 前或后,true前,false后</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">zeroFormat</span><span class="params">(Integer num, <span class="type">int</span> len, <span class="type">boolean</span> prev)</span> {</span><br><span class="line"> <span class="type">int</span> <span class="variable">l</span> <span class="operator">=</span> num.toString().length();</span><br><span class="line"> <span class="type">StringBuffer</span> <span class="variable">sb</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">StringBuffer</span>();</span><br><span class="line"> <span class="keyword">if</span>(!prev)</span><br><span class="line"> sb.append(num);<span class="comment">//后补</span></span><br><span class="line"> <span class="keyword">for</span>(<span class="type">int</span> i=<span class="number">0</span>;i<len-l;i++)</span><br><span class="line"> sb.append(<span class="string">"0"</span>);</span><br><span class="line"> <span class="keyword">if</span>(prev)</span><br><span class="line"> sb.append(num);<span class="comment">//前补</span></span><br><span class="line"> <span class="keyword">return</span> sb.toString();</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h4 id="使用自带的String-Format方法"><a href="#使用自带的String-Format方法" class="headerlink" title="使用自带的String.Format方法"></a>使用自带的String.Format方法</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//前补零</span></span><br><span class="line"><span class="type">String</span> <span class="variable">str1</span> <span class="operator">=</span> String.format(<span class="string">"%05d"</span>, <span class="number">12</span>);</span><br><span class="line">System.out.println(str1);<span class="comment">//00012</span></span><br><span class="line"> </span><br><span class="line"><span class="comment">//后补零</span></span><br><span class="line"><span class="type">String</span> <span class="variable">num</span> <span class="operator">=</span> <span class="string">"12"</span>;</span><br><span class="line"><span class="type">int</span> <span class="variable">len</span> <span class="operator">=</span> <span class="number">5</span>;</span><br><span class="line"><span class="type">String</span> <span class="variable">str2</span> <span class="operator">=</span> num + String.format(<span class="string">"%0"</span>+(len - num.length())+<span class="string">"d"</span>, <span class="number">0</span>);</span><br><span class="line">System.out.println(str2);<span class="comment">//12000</span></span><br></pre></td></tr></table></figure><h4 id="使用Number、DecimalFormat"><a href="#使用Number、DecimalFormat" class="headerlink" title="使用Number、DecimalFormat"></a>使用Number、DecimalFormat</h4><p>支持小数、负数、货币、百分比等等各种操作</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//前补零</span></span><br><span class="line"><span class="type">String</span> <span class="variable">str1</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">DecimalFormat</span>(<span class="string">"00000"</span>).format(<span class="number">12</span>);</span><br><span class="line">System.out.println(str1);<span class="comment">//00012</span></span><br><span class="line"><span class="type">String</span> <span class="variable">str2</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">DecimalFormat</span>(<span class="string">"00000.000"</span>).format(<span class="number">12.12</span>);</span><br><span class="line">System.out.println(str2);<span class="comment">//00012.120</span></span><br><span class="line"> </span><br><span class="line"><span class="type">NumberFormat</span> <span class="variable">formatter</span> <span class="operator">=</span> NumberFormat.getNumberInstance();</span><br><span class="line">formatter.setGroupingUsed(<span class="literal">false</span>);<span class="comment">//不分组</span></span><br><span class="line">formatter.setMinimumIntegerDigits(<span class="number">5</span>);<span class="comment">//整数部分中所允许的最小数字位数</span></span><br><span class="line"><span class="comment">//formatter.setMinimumFractionDigits(3);//小数部分中所允许的最小数字位数</span></span><br><span class="line"><span class="type">String</span> <span class="variable">str3</span> <span class="operator">=</span> formatter.format(<span class="number">12</span>);</span><br><span class="line">System.out.println(str3);<span class="comment">//00012</span></span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"><span class="comment">//后面补零</span></span><br><span class="line"><span class="type">Integer</span> <span class="variable">num</span> <span class="operator">=</span> <span class="number">12</span>;</span><br><span class="line"><span class="type">int</span> <span class="variable">len</span> <span class="operator">=</span> <span class="number">5</span>;</span><br><span class="line"><span class="type">int</span> <span class="variable">l</span> <span class="operator">=</span> len - num.toString().length();</span><br><span class="line"> </span><br><span class="line"><span class="type">DecimalFormat</span> <span class="variable">df</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">DecimalFormat</span>();</span><br><span class="line">df.setGroupingUsed(<span class="literal">false</span>);</span><br><span class="line">df.setMinimumIntegerDigits(len);</span><br><span class="line"><span class="keyword">if</span>(l><span class="number">0</span>)</span><br><span class="line"> df.setMultiplier((<span class="type">int</span>)Math.pow(<span class="number">10</span>,l));</span><br><span class="line">System.out.println(df.format(num));<span class="comment">//12000</span></span><br></pre></td></tr></table></figure><hr><h2 id="Switch-语句"><a href="#Switch-语句" class="headerlink" title="Switch 语句"></a>Switch 语句</h2><h3 id="switch-支持的数据类型"><a href="#switch-支持的数据类型" class="headerlink" title="switch 支持的数据类型"></a>switch 支持的数据类型</h3><ul><li>Java 7 中加入了对String类型的支持。所以支持的有:char、byte、short、int 和 Character、Byte、Short、Integer 和 String</li></ul><hr><h2 id="接口与抽象类的区别"><a href="#接口与抽象类的区别" class="headerlink" title="接口与抽象类的区别"></a>接口与抽象类的区别</h2><h3 id="接口"><a href="#接口" class="headerlink" title="接口"></a>接口</h3><p>接口是一个特殊的类, 使用的是 interface 修饰的类 实现接口需要使用implements</p><p>接口的作用: 制定规则</p><p> 降低耦合</p><ul><li><strong>接口中的所有方法都是抽象方法, 没有方法体, 如果想要有具体的实现, 需要使用default修饰词</strong></li><li><strong>接口中的属性默认都是常量</strong></li><li><strong>接口中的方法不能使用private修饰, 但java 9 之后可以使用了</strong></li><li><strong>接口与接口之间可以多继承, 但不能互相实现</strong></li><li><strong>接口之中没有构造方法,这就是为什么接口不能被实例化</strong></li><li><strong>java8之前接口是不能有静态方法的,java8之后可以,但是只能由接口类自己调用。</strong></li></ul><h3 id="抽象类"><a href="#抽象类" class="headerlink" title="抽象类"></a>抽象类</h3><p>抽象类使用abstract 修饰的类 继承抽象类使用的是extends</p><p>抽象类的作用是: <strong>降低接口与接口实现类之间实现复杂度的问题</strong></p><ul><li><strong>抽象类中的方法可以是抽象方法,也可以有具体的实现</strong></li><li><strong>抽象类继承一个接口时, 可以不需要实现接口中的所有方法</strong></li><li><strong>抽象类声明的方法必须由子类进行重写</strong></li><li><strong>抽象类中是有构造方法的(但是抽象类不能实例化)</strong></li><li><strong>抽象类可以有静态方法</strong></li></ul><h3 id="使用选择"><a href="#使用选择" class="headerlink" title="使用选择"></a>使用选择</h3><h4 id="使用接口"><a href="#使用接口" class="headerlink" title="使用接口"></a>使用接口</h4><p>需要让不相关的类都实现一个方法</p><p>需要使用多继承</p><h4 id="使用抽象类"><a href="#使用抽象类" class="headerlink" title="使用抽象类"></a>使用抽象类</h4><p>需要在几个相关的类中共享代码。</p><p>需要能控制继承来的成员的访问权限,而不不是都为 public。</p><p>需要继承非静态和非常量字段。</p><hr><h2 id="重写与重载的区别"><a href="#重写与重载的区别" class="headerlink" title="重写与重载的区别"></a>重写与重载的区别</h2><h3 id="重载"><a href="#重载" class="headerlink" title="重载"></a>重载</h3><p>重载是指: 一个类中可以有多个方法拥有同样的方法名, 具有不同的参数列表</p><p>重载的作用是使用相同的对象, 调用相同的方法, 使用不同的参数列表, 实现不同的功能</p><p>被final修饰的方法是可以被重载的。</p><h3 id="重写"><a href="#重写" class="headerlink" title="重写"></a>重写</h3><p>重写是指: 子类继承父类中, 并对父类中的方法进行重新定义</p><ul><li><p>具有final 或者 private修饰的方法不能被重写</p></li><li><p>重写的方法不能抛出比父类方法更多的异常</p></li><li><p>重写的方法可以扩大他的访问权限, 但可以缩小他的访问权限</p></li><li><p>重写方法的返回值可以缩小, 但不能扩大</p></li></ul><hr><h2 id="反射"><a href="#反射" class="headerlink" title="反射"></a>反射</h2><p>反射的优点:</p><pre><code> - 可扩展性: 应用程序可以利用全限定名创建可扩展对象的实例, 来使用来自外部的用户的自定义类 - 类浏览器和可视化开发环境: 一个类浏览器需要可以枚举类的成员. 可视化开发环境(如IDE) 可以利用反射中可用的类型信息中受益, 以帮助程序员编写正确的代码.</code></pre><p>反射的缺点:</p><ul><li>性能开销</li><li>安全限制</li><li>内部暴露</li></ul><p>java中获取Class类的三种方式:</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// java中获取反射的三种方式</span></span><br><span class="line"> LOGGER.info(<span class="string">"根据类名:"</span>+User.class);</span><br><span class="line"> LOGGER.info(<span class="string">"根据对象:"</span> + <span class="keyword">new</span> <span class="title class_">User</span>().getClass());</span><br><span class="line"> LOGGER.info(<span class="string">"根据全限定类名:"</span> + Class.forName(<span class="string">"org.example.entity.User"</span>));</span><br><span class="line"> <span class="comment">// 常使用的方法</span></span><br><span class="line"> <span class="type">Class</span> <span class="variable">userClass</span> <span class="operator">=</span> Class.forName(<span class="string">"org.example.entity.User"</span>);</span><br><span class="line"> LOGGER.info(<span class="string">"获取全限定类名:"</span> + userClass.getName());</span><br><span class="line"> LOGGER.info(<span class="string">"获取类名:"</span> + userClass.getSimpleName());</span><br><span class="line"> LOGGER.info(<span class="string">"获取实例对象:"</span> + userClass.newInstance());</span><br></pre></td></tr></table></figure><hr><h2 id="异常"><a href="#异常" class="headerlink" title="异常"></a>异常</h2><p><img src="https://ryu2u-1305537946.cos.ap-nanjing.myqcloud.com/images/image-20220308145041764.png" alt="image-20220308145041764"></p><h2 id="this()与super()在构造方法中的作用"><a href="#this()与super()在构造方法中的作用" class="headerlink" title="this()与super()在构造方法中的作用"></a>this()与super()在构造方法中的作用</h2><ul><li>调用super()必须在构造方法的第一行</li><li>super()在子类中调用父类构造,this()在同一类中调用其他构造都必须放在同一行。</li><li>尽管可以使用this()调用其他构造,但不能调用两个。</li><li>this和super不能出现在同一个构造器中。</li><li>this和super都指的是对象,不能在static中使用。</li><li>本质this是一个指针,super是关键字。</li></ul><hr><h2 id="java位移运算符"><a href="#java位移运算符" class="headerlink" title="java位移运算符"></a>java位移运算符</h2><p>java中有三种位移运算符</p><ul><li><< 左位移运算符,<code>x<<1</code>将x左移一位,相当于将x乘2,低位补0。</li><li>>> 右位移运算符,<code>x>>1</code>将x右移一位,相当于将x除2,高位补1。</li><li>>>> 无符号右移,忽略符号位,空位都以0补齐。</li></ul><hr><h2 id="java中的泛型"><a href="#java中的泛型" class="headerlink" title="java中的泛型"></a>java中的泛型</h2><p>java中的泛型可以在类中声明,也可以使用在方法上。</p><p>泛型中的类在使用时指定,不需要强制转换。</p><p>这是因为java中的泛型是伪泛型:</p><p>因为java中使用了泛型类型擦除,java1.5引入了泛型这个概念,为了兼容之前的版本,java 的泛型使用了伪泛型的策略,即java语言在语法上支持泛型,但在编译时会进行泛型类型擦除,编译器会将类型自动转换为指定的类型,就像没有泛型一样。</p><h3 id="为什么要使用泛型?"><a href="#为什么要使用泛型?" class="headerlink" title="为什么要使用泛型?"></a>为什么要使用泛型?</h3><p>使用泛型可以将多个使用不同类型的方法复用为一个代码。</p><hr><h2 id="java-的注解"><a href="#java-的注解" class="headerlink" title="java 的注解"></a>java 的注解</h2><p>java 自带的标准注解有:@Override、@Deprecated和@SuppressWarnings,分别用来表示:重写某个方法、声明某个方法过时、声明需要忽略的警告。</p><p><strong>元注解:</strong>值用来注解注解类的注解</p><ul><li>@Retention 用于标明注解被保留的阶段</li><li>@Target 用于标明注解使用的范围</li><li>@Inherited 用于标明注解可继承</li><li>@Documented 用于标明是否生成javadoc文档</li></ul><p>在java中可以自定义注解的使用</p><h2 id="Lambda-表达式"><a href="#Lambda-表达式" class="headerlink" title="Lambda 表达式"></a>Lambda 表达式</h2><p>lambda表达式时java8中新增的一个特性,它可以对某些匿名内部类的写法进行简化。他是函数式编程思想的一个重要体现,<strong>让我们不再关注时什么对象,而是更关注于我们对数据进行了什么操作。</strong></p><p>Lambda表达式的好处:</p><ul><li>代码可读性高</li><li>大数量下处理集合效率高</li><li>代码简洁</li><li>易于并发编程</li><li>接近自然语言,易于理解</li></ul><h3 id="函数式编程思想"><a href="#函数式编程思想" class="headerlink" title="函数式编程思想"></a>函数式编程思想</h3><p>面向对象思想需要关注使用什么对象完成什么事情,而函数式编程思想就类似于我们数学中的函数,它主要关注的是对数据进行了什么操作。</p><h3 id="Lambda-表达式的使用"><a href="#Lambda-表达式的使用" class="headerlink" title="Lambda 表达式的使用"></a>Lambda 表达式的使用</h3><p>使用Lambda表达式实现接口时,只能实现只有一个方法的接口。</p><h3 id="Stream流"><a href="#Stream流" class="headerlink" title="Stream流"></a>Stream流</h3><p>java8的Stream流使用的是函数式编程模式,如同他的名字一样,他可以被用来对集合或数组进行链状流式的操作,可以更方便的让我们对集合或数组操作。</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">authors.stream()</span><br><span class="line"> <span class="comment">//去重</span></span><br><span class="line"> .distinct()</span><br><span class="line"> <span class="comment">//过滤,条件:年龄小于18</span></span><br><span class="line"> .filter(author -> author.getAge() < <span class="number">18</span>)</span><br><span class="line"> <span class="comment">//遍历打印</span></span><br><span class="line"> .forEach(author -> System.out.println(author.getName()));</span><br></pre></td></tr></table></figure><h4 id="创建流"><a href="#创建流" class="headerlink" title="创建流"></a>创建流</h4><p>单列集合:<code>集合对象.stream()</code></p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Stream<Author> stream = authors.stream();</span><br></pre></td></tr></table></figure><p>数组:<code>Arrays.stream(数组)</code>或者使用<code>stream.of</code>来创建</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Stream<Integer> stream1 = Arrays.stream(arr);</span><br><span class="line">Stream<Integer> stream2 = Stream.of(arr);</span><br></pre></td></tr></table></figure><p>双列集合:转换成单列集合后zai创建</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Stream<Map.Entry<String,Integer>> stream = map.entrySet().stream();</span><br></pre></td></tr></table></figure><h4 id="中间操作"><a href="#中间操作" class="headerlink" title="中间操作"></a>中间操作</h4><p>filter:用于过滤</p><p>distinct:用于去重</p><p>sorted:用于排序,无参方法需要实现comparable接口,有参方法需要实现接口comparator中的方法。</p><p>limit:用于设置流的最大长度,可以截取集合中前几个元素</p><p>skip:跳过集合中的前nge</p>]]></content>
<categories>
<category> Java </category>
</categories>
</entry>
<entry>
<title>SecondPost</title>
<link href="/2022/07/28/SecondPost/"/>
<url>/2022/07/28/SecondPost/</url>
<content type="html"><![CDATA[]]></content>
</entry>
<entry>
<title>MarkDown语法</title>
<link href="/2022/07/28/MarkDown%E8%AF%AD%E6%B3%95/"/>
<url>/2022/07/28/MarkDown%E8%AF%AD%E6%B3%95/</url>
<content type="html"><![CDATA[<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">使用[toc]可以生成目录,只要是标题都可以显示</span><br></pre></td></tr></table></figure><p><em><strong>可以在视图->源代码模式进行(Ctrl + / ) 进行查看源代码模式</strong></em></p><p>Ctrl+加号/减号 可以放大缩小文字</p><p>Ctrl+Shift+加号/减号 可以放大缩小页面</p><h3 id="上标与下标"><a href="#上标与下标" class="headerlink" title="上标与下标"></a>上标与下标</h3><p>例如:2^8^ 和 2<del>8</del> </p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">上标: 2^8^</span><br><span class="line">下标: 2~8~</span><br></pre></td></tr></table></figure><h3 id="标题"><a href="#标题" class="headerlink" title="标题"></a>标题</h3><h1 id="一级标题"><a href="#一级标题" class="headerlink" title="一级标题"></a>一级标题</h1><h2 id="二级标题"><a href="#二级标题" class="headerlink" title="二级标题"></a>二级标题</h2><h3 id="三级标题"><a href="#三级标题" class="headerlink" title="三级标题"></a>三级标题</h3><h4 id="四级标题"><a href="#四级标题" class="headerlink" title="四级标题"></a>四级标题</h4><h5 id="五级标题"><a href="#五级标题" class="headerlink" title="五级标题"></a>五级标题</h5><h6 id="六级标题"><a href="#六级标题" class="headerlink" title="六级标题"></a>六级标题</h6><p>也可以直接使用Ctrl+数字</p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">就是一个# 快捷键</span><br><span class="line">最多六个# 六级标题</span><br></pre></td></tr></table></figure><h3 id="超链接"><a href="#超链接" class="headerlink" title="超链接"></a>超链接</h3><p><a href="www.baidu.com">百度</a></p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">第一种: \http://www.baidu.com</span><br><span class="line">第二种:快捷键Ctrl + k</span><br><span class="line">[自定义内容](超链接地址) 例如:[百度一下](www.baidu.com)</span><br><span class="line">按住Ctrl键+点击上面链接就可以直接访问该链接</span><br></pre></td></tr></table></figure><h3 id="文本居中"><a href="#文本居中" class="headerlink" title="文本居中"></a>文本居中</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag"><<span class="name">center</span>></span>这是要居中的文本内容<span class="tag"></<span class="name">center</span>></span></span><br></pre></td></tr></table></figure><h3 id="下划线"><a href="#下划线" class="headerlink" title="下划线"></a>下划线</h3><p>效果 <u>下划线</u></p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag"><<span class="name">u</span>></span>下划线<span class="tag"></<span class="name">u</span>></span> 快捷键 Ctrl+U</span><br></pre></td></tr></table></figure><h3 id="删除线"><a href="#删除线" class="headerlink" title="删除线"></a>删除线</h3><p>效果: <del>删除线</del></p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">~~删除线~~</span><br></pre></td></tr></table></figure><h3 id="文字加粗"><a href="#文字加粗" class="headerlink" title="文字加粗"></a>文字加粗</h3><p>效果: <strong>加粗</strong></p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">**加粗字体** 或者快捷键 Ctrl + B</span><br></pre></td></tr></table></figure><h3 id="文件倾斜"><a href="#文件倾斜" class="headerlink" title="文件倾斜"></a>文件倾斜</h3><p><em>倾斜</em></p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">*倾斜字体* 或者快捷键 Ctrl + I</span><br></pre></td></tr></table></figure><h3 id="图片插入"><a href="#图片插入" class="headerlink" title="图片插入"></a>图片插入</h3><p>直接拖 或者 快捷键 Ctrl+Shift+I</p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">![这里写图片描述](这里图片地址,url或者本地都可以)</span><br></pre></td></tr></table></figure><h3 id="任务列表"><a href="#任务列表" class="headerlink" title="任务列表"></a>任务列表</h3><p>效果:</p><ul><li><p><input checked="" disabled="" type="checkbox"> java</p><ul><li><p><input checked="" disabled="" type="checkbox"> python</p><ul><li><p><input checked="" disabled="" type="checkbox"> html</p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">- [x] java</span><br><span class="line">- [ ] python</span><br><span class="line"> - [ ] py1</span><br><span class="line"> - [x] py2</span><br></pre></td></tr></table></figure></li></ul></li></ul></li></ul><h3 id="列表"><a href="#列表" class="headerlink" title="列表"></a>列表</h3><h5 id="有序列表"><a href="#有序列表" class="headerlink" title="有序列表"></a>有序列表</h5><ol start="2"><li><p>有序1</p></li><li><p>有序2</p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">任意 数字+点+空格 创建有序列表</span><br></pre></td></tr></table></figure></li></ol><h5 id="无序列表"><a href="#无序列表" class="headerlink" title="无序列表"></a>无序列表</h5><ul><li><p>无序1</p><ul><li><p>无序2</p><p>+ 无序</p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">\+ 、- 、* + 空格 创建无序列</span><br></pre></td></tr></table></figure></li></ul></li></ul><h3 id="表格"><a href="#表格" class="headerlink" title="表格"></a>表格</h3><p>第一种:快捷键<strong>Ctrl+T</strong>,会自动跳出设置行和列的设置框<br>第二种:<br>效果:</p><table><thead><tr><th>第一行</th><th align="left">test</th><th>test</th></tr></thead><tbody><tr><td>第二行</td><td align="left">test</td><td>test</td></tr></tbody></table><h3 id="数学表达式"><a href="#数学表达式" class="headerlink" title="数学表达式"></a>数学表达式</h3><p>Typora支持加入用LaTeX写成的数学公式,并且在软件界面下用MathJax直接渲染。<br>数学公式分为两种:<br>一种是行内公式(inline math),可以在偏好设置中单独打开,由一个美元符号$将公式围起来;<br>一种是行外公式,直接按<strong>Ctrl+Shift+M</strong>;</p><p>注:上标和下标可以使用数学表达式来获取</p><p>语法为 <code>$数学表达式$</code></p><p>分数的语法为<code>\frac</code></p><p>$\frac {12}{343}$</p><h3 id="画图"><a href="#画图" class="headerlink" title="画图"></a>画图</h3><p>~~~mermaid</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">graph TD;</span><br><span class="line"> A-->B;</span><br><span class="line"> A-->C;</span><br><span class="line"> B-->D;</span><br><span class="line"></span><br></pre></td></tr></table></figure><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">graph LR;</span><br><span class="line">A-->B;</span><br><span class="line"> A-->C;</span><br><span class="line"> B-->D;</span><br></pre></td></tr></table></figure><h3 id="水平分割线"><a href="#水平分割线" class="headerlink" title="水平分割线"></a>水平分割线</h3><hr><hr><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">***加Enter</span><br><span class="line">---加Enter</span><br></pre></td></tr></table></figure><h3 id="引用"><a href="#引用" class="headerlink" title="引用"></a>引用</h3><blockquote><p> 引用效果 </p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">>+空格</span><br></pre></td></tr></table></figure></blockquote><h3 id="注释"><a href="#注释" class="headerlink" title="注释"></a>注释</h3><p>效果: [^ 这是一个注释]</p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">语法: [^要注释的内容]</span><br></pre></td></tr></table></figure><h3 id="快捷键一览"><a href="#快捷键一览" class="headerlink" title="快捷键一览"></a>快捷键一览</h3><table><thead><tr><th>快捷键</th><th>作用</th><th>快捷键</th><th>作用</th></tr></thead><tbody><tr><td>Ctrl+1</td><td>一阶标题</td><td>Ctrl+B</td><td>字体加粗</td></tr><tr><td>Ctrl+2</td><td>二阶标题</td><td>Ctrl+I</td><td>字体倾斜</td></tr><tr><td>Ctrl+3</td><td>三阶标题</td><td>Ctrl+U</td><td>下划线</td></tr><tr><td>Ctrl+4</td><td>四阶标题</td><td>Ctrl+Home</td><td>返回Typora顶部</td></tr><tr><td>Ctrl+5</td><td>五阶标题</td><td>Ctrl+End</td><td>返回Typora底部</td></tr><tr><td>Ctrl+6</td><td>六阶标题</td><td>Ctrl+T</td><td>创建表格</td></tr><tr><td>Ctrl+L</td><td>选中某句话</td><td>Ctrl+K</td><td>创建超链接</td></tr><tr><td>Ctrl+D</td><td>选中某个单词</td><td>Ctrl+F</td><td>搜索</td></tr><tr><td>Ctrl+E</td><td>选中相同格式的文字</td><td>Ctrl+H</td><td>搜索并替换</td></tr><tr><td>Alt+Shift+5</td><td>删除线</td><td>Ctrl+Shift+I</td><td>插入图片</td></tr></tbody></table><p>[^ 这是一个注释]: </p>]]></content>
<tags>
<tag> markdown </tag>
</tags>
</entry>
<entry>
<title>Hello World</title>
<link href="/2022/07/27/hello-world/"/>
<url>/2022/07/27/hello-world/</url>
<content type="html"><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p><p>Hello Hexo 这是我的第一个博客文章.</p><h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p><h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p><h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p><h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>]]></content>
</entry>
</search>