Skip to content

Commit

Permalink
Site updated: 2024-04-15 15:08:09
Browse files Browse the repository at this point in the history
  • Loading branch information
BellaCiao283036 committed Apr 15, 2024
1 parent dc3c18b commit f3943a9
Show file tree
Hide file tree
Showing 34 changed files with 1,719 additions and 364 deletions.
775 changes: 775 additions & 0 deletions 2024/04/15/Default-And-Static-Methods-In-Interface/index.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
<meta name="author" content="倪京龙">
<meta name="keywords" content="Technology,Life,Programming,Java,JavaScript,System Design,MySQL,Spring,倪京龙,Linux">

<meta name="description" content="Introduction">
<meta name="description" content="IntroductionJava 8 引入了可重复注解 @Repeatable 的功能,允许相同的注解可以在同一个元素上多次使用。 In Practice定义可重复注解及其容器注解12345678910111213141516import java.lang.annotation.*;&#x2F;&#x2F; 定义可重复注解@Repeatable(Authors.class) &#x2F;&#x2F; 传入容器注解作为参数@Retent">
<meta property="og:type" content="article">
<meta property="og:title" content="Default Methods In Interface">
<meta property="og:url" content="https://stein283036.github.io/2024/04/15/Default-Methods-In-Interface/">
<meta property="og:title" content="Java 8 Repeating Annotations">
<meta property="og:url" content="https://stein283036.github.io/2024/04/15/Java-8-Repeating-Annotations/">
<meta property="og:site_name" content="倪京龙的个人博客">
<meta property="og:description" content="Introduction">
<meta property="og:description" content="IntroductionJava 8 引入了可重复注解 @Repeatable 的功能,允许相同的注解可以在同一个元素上多次使用。 In Practice定义可重复注解及其容器注解12345678910111213141516import java.lang.annotation.*;&#x2F;&#x2F; 定义可重复注解@Repeatable(Authors.class) &#x2F;&#x2F; 传入容器注解作为参数@Retent">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2024-04-15T06:34:20.000Z">
<meta property="article:modified_time" content="2024-04-15T06:34:40.408Z">
<meta property="article:published_time" content="2024-04-15T06:50:02.000Z">
<meta property="article:modified_time" content="2024-04-15T06:55:43.266Z">
<meta property="article:author" content="倪京龙">
<meta property="article:tag" content="Java Annotations">
<meta property="article:tag" content="Java 8">
<meta property="article:tag" content="Interface">
<meta name="twitter:card" content="summary_large_image">



<title>Default Methods In Interface - 倪京龙的个人博客</title>
<title>Java 8 Repeating Annotations - 倪京龙的个人博客</title>

<link rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />

Expand Down Expand Up @@ -239,7 +239,7 @@
<div class="banner-text text-center fade-in-up">
<div class="h2">

<span id="subtitle" data-typed-text="Default Methods In Interface"></span>
<span id="subtitle" data-typed-text="Java 8 Repeating Annotations"></span>

</div>

Expand All @@ -250,7 +250,7 @@

<span class="post-meta">
<i class="iconfont icon-date-fill" aria-hidden="true"></i>
<time datetime="2024-04-15 14:34" pubdate>
<time datetime="2024-04-15 14:50" pubdate>
2024年4月15日 下午
</time>
</span>
Expand All @@ -262,7 +262,7 @@
<span class="post-meta mr-2">
<i class="iconfont icon-chart"></i>

1
211

</span>

Expand All @@ -273,7 +273,7 @@



1 分钟
2 分钟

</span>

Expand Down Expand Up @@ -318,7 +318,7 @@
<div class="container nopadding-x-md" id="board-ctn">
<div id="board">
<article class="post-content mx-auto">
<h1 id="seo-header">Default Methods In Interface</h1>
<h1 id="seo-header">Java 8 Repeating Annotations</h1>

<p id="updated-time" class="note note-info" style="">

Expand All @@ -331,7 +331,13 @@ <h1 id="seo-header">Default Methods In Interface</h1>

<div class="markdown-body">

<h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduction"></a>Introduction</h2>
<h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduction"></a>Introduction</h2><p>Java 8 引入了可重复注解 <code>@Repeatable</code> 的功能,允许相同的注解可以在同一个元素上多次使用。</p>
<h2 id="In-Practice"><a href="#In-Practice" class="headerlink" title="In Practice"></a>In Practice</h2><h3 id="定义可重复注解及其容器注解"><a href="#定义可重复注解及其容器注解" class="headerlink" title="定义可重复注解及其容器注解"></a>定义可重复注解及其容器注解</h3><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></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">import</span> java.lang.annotation.*;<br><br><span class="hljs-comment">// 定义可重复注解</span><br><span class="hljs-meta">@Repeatable(Authors.class)</span> <span class="hljs-comment">// 传入容器注解作为参数</span><br><span class="hljs-meta">@Retention(RetentionPolicy.RUNTIME)</span><br><span class="hljs-meta">@Target(ElementType.TYPE)</span><br><span class="hljs-meta">@interface</span> Author &#123;<br> String <span class="hljs-title function_">name</span><span class="hljs-params">()</span>;<br>&#125;<br><br><span class="hljs-comment">// 定义容器注解</span><br><span class="hljs-meta">@Retention(RetentionPolicy.RUNTIME)</span><br><span class="hljs-meta">@Target(ElementType.TYPE)</span><br><span class="hljs-meta">@interface</span> Authors &#123;<br> Author[] value();<br>&#125;<br></code></pre></td></tr></table></figure>

<h3 id="在类上使用可重复注解"><a href="#在类上使用可重复注解" class="headerlink" title="在类上使用可重复注解"></a>在类上使用可重复注解</h3><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><code class="hljs java"><span class="hljs-meta">@Author(name = &quot;John&quot;)</span><br><span class="hljs-meta">@Author(name = &quot;Doe&quot;)</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">Book</span> &#123;<br> <span class="hljs-comment">// 类的内容...</span><br>&#125;<br></code></pre></td></tr></table></figure>

<h3 id="获取可重复注解的值"><a href="#获取可重复注解的值" class="headerlink" title="获取可重复注解的值"></a>获取可重复注解的值</h3><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></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">import</span> java.lang.annotation.Annotation;<br><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">Main</span> &#123;<br> <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">main</span><span class="hljs-params">(String[] args)</span> &#123;<br> <span class="hljs-comment">// 获取类上的 Authors 注解,这里需要获取容器注解 Authors 而不是 Author 注解</span><br> <span class="hljs-type">Authors</span> <span class="hljs-variable">authors</span> <span class="hljs-operator">=</span> Book.class.getAnnotation(Authors.class);<br> <span class="hljs-comment">// 获取 Authors 注解中的所有 Author 注解</span><br> Author[] authorArray = authors.value();<br> <span class="hljs-comment">// 遍历 Author 注解,获取 name 属性值</span><br> <span class="hljs-keyword">for</span> (Author author : authorArray) &#123;<br> System.out.println(<span class="hljs-string">&quot;Author: &quot;</span> + author.name());<br> &#125;<br> &#125;<br>&#125;<br></code></pre></td></tr></table></figure>


</div>

Expand Down Expand Up @@ -364,9 +370,9 @@ <h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduc
<div class="post-meta">
<i class="iconfont icon-tags"></i>

<a href="/tags/Java-8/" class="print-no-link">#Java 8</a>
<a href="/tags/Java-Annotations/" class="print-no-link">#Java Annotations</a>

<a href="/tags/Interface/" class="print-no-link">#Interface</a>
<a href="/tags/Java-8/" class="print-no-link">#Java 8</a>

</div>

Expand All @@ -378,8 +384,8 @@ <h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduc

<div class="license-box my-3">
<div class="license-title">
<div>Default Methods In Interface</div>
<div>https://stein283036.github.io/2024/04/15/Default-Methods-In-Interface/</div>
<div>Java 8 Repeating Annotations</div>
<div>https://stein283036.github.io/2024/04/15/Java-8-Repeating-Annotations/</div>
</div>
<div class="license-meta">

Expand Down Expand Up @@ -432,8 +438,8 @@ <h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduc
<article class="post-next col-6">


<a href="/2024/04/15/Java-Objects/" title="Java Objects">
<span class="hidden-mobile">Java Objects</span>
<a href="/2024/04/15/Default-And-Static-Methods-In-Interface/" title="Default And Static Methods In Interface">
<span class="hidden-mobile">Default And Static Methods In Interface</span>
<span class="visible-mobile">下一篇</span>
<i class="iconfont icon-arrowright"></i>
</a>
Expand Down
4 changes: 2 additions & 2 deletions 2024/04/15/Java-Objects/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,9 @@ <h2 id="In-Practice"><a href="#In-Practice" class="headerlink" title="In Practic
<article class="post-prev col-6">


<a href="/2024/04/15/Default-Methods-In-Interface/" title="Default Methods In Interface">
<a href="/2024/04/15/Default-And-Static-Methods-In-Interface/" title="Default And Static Methods In Interface">
<i class="iconfont icon-arrowleft"></i>
<span class="hidden-mobile">Default Methods In Interface</span>
<span class="hidden-mobile">Default And Static Methods In Interface</span>
<span class="visible-mobile">上一篇</span>
</a>

Expand Down
2 changes: 1 addition & 1 deletion archives/2024/03/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@


<div class="list-group">
<p class="h4">共计 43 篇文章</p>
<p class="h4">共计 44 篇文章</p>
<hr>


Expand Down
2 changes: 1 addition & 1 deletion archives/2024/03/page/2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@


<div class="list-group">
<p class="h4">共计 43 篇文章</p>
<p class="h4">共计 44 篇文章</p>
<hr>


Expand Down
2 changes: 1 addition & 1 deletion archives/2024/03/page/3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@


<div class="list-group">
<p class="h4">共计 43 篇文章</p>
<p class="h4">共计 44 篇文章</p>
<hr>


Expand Down
2 changes: 1 addition & 1 deletion archives/2024/03/page/4/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@


<div class="list-group">
<p class="h4">共计 43 篇文章</p>
<p class="h4">共计 44 篇文章</p>
<hr>


Expand Down
18 changes: 9 additions & 9 deletions archives/2024/04/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,17 +258,23 @@


<div class="list-group">
<p class="h4">共计 43 篇文章</p>
<p class="h4">共计 44 篇文章</p>
<hr>




<p class="h5">2024</p>

<a href="/2024/04/15/Default-Methods-In-Interface/" class="list-group-item list-group-item-action">
<a href="/2024/04/15/Java-8-Repeating-Annotations/" class="list-group-item list-group-item-action">
<time>04-15</time>
<div class="list-group-item-title">Default Methods In Interface</div>
<div class="list-group-item-title">Java 8 Repeating Annotations</div>
</a>


<a href="/2024/04/15/Default-And-Static-Methods-In-Interface/" class="list-group-item list-group-item-action">
<time>04-15</time>
<div class="list-group-item-title">Default And Static Methods In Interface</div>
</a>


Expand Down Expand Up @@ -319,12 +325,6 @@
<div class="list-group-item-title">Vocabulary 14</div>
</a>


<a href="/2024/04/01/Vocabulary-13/" class="list-group-item list-group-item-action">
<time>04-01</time>
<div class="list-group-item-title">Vocabulary 13</div>
</a>

</div>


Expand Down
8 changes: 7 additions & 1 deletion archives/2024/04/page/2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,20 @@


<div class="list-group">
<p class="h4">共计 43 篇文章</p>
<p class="h4">共计 44 篇文章</p>
<hr>




<p class="h5">2024</p>

<a href="/2024/04/01/Vocabulary-13/" class="list-group-item list-group-item-action">
<time>04-01</time>
<div class="list-group-item-title">Vocabulary 13</div>
</a>


<a href="/2024/04/01/Vocabulary-12/" class="list-group-item list-group-item-action">
<time>04-01</time>
<div class="list-group-item-title">Vocabulary 12</div>
Expand Down
18 changes: 9 additions & 9 deletions archives/2024/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,17 +258,23 @@


<div class="list-group">
<p class="h4">共计 43 篇文章</p>
<p class="h4">共计 44 篇文章</p>
<hr>




<p class="h5">2024</p>

<a href="/2024/04/15/Default-Methods-In-Interface/" class="list-group-item list-group-item-action">
<a href="/2024/04/15/Java-8-Repeating-Annotations/" class="list-group-item list-group-item-action">
<time>04-15</time>
<div class="list-group-item-title">Default Methods In Interface</div>
<div class="list-group-item-title">Java 8 Repeating Annotations</div>
</a>


<a href="/2024/04/15/Default-And-Static-Methods-In-Interface/" class="list-group-item list-group-item-action">
<time>04-15</time>
<div class="list-group-item-title">Default And Static Methods In Interface</div>
</a>


Expand Down Expand Up @@ -319,12 +325,6 @@
<div class="list-group-item-title">Vocabulary 14</div>
</a>


<a href="/2024/04/01/Vocabulary-13/" class="list-group-item list-group-item-action">
<time>04-01</time>
<div class="list-group-item-title">Vocabulary 13</div>
</a>

</div>


Expand Down
14 changes: 7 additions & 7 deletions archives/2024/page/2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,20 @@


<div class="list-group">
<p class="h4">共计 43 篇文章</p>
<p class="h4">共计 44 篇文章</p>
<hr>




<p class="h5">2024</p>

<a href="/2024/04/01/Vocabulary-13/" class="list-group-item list-group-item-action">
<time>04-01</time>
<div class="list-group-item-title">Vocabulary 13</div>
</a>


<a href="/2024/04/01/Vocabulary-12/" class="list-group-item list-group-item-action">
<time>04-01</time>
<div class="list-group-item-title">Vocabulary 12</div>
Expand Down Expand Up @@ -319,12 +325,6 @@
<div class="list-group-item-title">Vocabulary 04</div>
</a>


<a href="/2024/03/25/Vocabulary-03/" class="list-group-item list-group-item-action">
<time>03-25</time>
<div class="list-group-item-title">Vocabulary 03</div>
</a>

</div>


Expand Down
14 changes: 7 additions & 7 deletions archives/2024/page/3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,20 @@


<div class="list-group">
<p class="h4">共计 43 篇文章</p>
<p class="h4">共计 44 篇文章</p>
<hr>




<p class="h5">2024</p>

<a href="/2024/03/25/Vocabulary-03/" class="list-group-item list-group-item-action">
<time>03-25</time>
<div class="list-group-item-title">Vocabulary 03</div>
</a>


<a href="/2024/03/25/Vocabulary-02/" class="list-group-item list-group-item-action">
<time>03-25</time>
<div class="list-group-item-title">Vocabulary 02</div>
Expand Down Expand Up @@ -319,12 +325,6 @@
<div class="list-group-item-title">2024 Schedule</div>
</a>


<a href="/2024/03/06/JavaScript-for%E2%80%A6in-Loop/" class="list-group-item list-group-item-action">
<time>03-06</time>
<div class="list-group-item-title">JavaScript for…in Loop</div>
</a>

</div>


Expand Down
14 changes: 7 additions & 7 deletions archives/2024/page/4/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,20 @@


<div class="list-group">
<p class="h4">共计 43 篇文章</p>
<p class="h4">共计 44 篇文章</p>
<hr>




<p class="h5">2024</p>

<a href="/2024/03/06/JavaScript-for%E2%80%A6in-Loop/" class="list-group-item list-group-item-action">
<time>03-06</time>
<div class="list-group-item-title">JavaScript for…in Loop</div>
</a>


<a href="/2024/03/06/JavaScript-Object-Properties/" class="list-group-item list-group-item-action">
<time>03-06</time>
<div class="list-group-item-title">JavaScript Object Properties</div>
Expand Down Expand Up @@ -319,12 +325,6 @@
<div class="list-group-item-title">JavaScript Spread Operator</div>
</a>


<a href="/2024/03/06/JavaScript-Default-Parameters/" class="list-group-item list-group-item-action">
<time>03-06</time>
<div class="list-group-item-title">JavaScript Default Parameters</div>
</a>

</div>


Expand Down
Loading

0 comments on commit f3943a9

Please sign in to comment.