android源碼出現的@字元代表什麼意思

來源:互聯網
上載者:User

1.背景

在android源碼中我們能看到各種以@開頭的字元,他們大多出現在注釋中,如下圖所示

但是可不要小看了它們地作用,昨天當我編譯源碼的時候,就在一個“@link”處報錯了,下面就總結下常用的@字元的意義。

2.總結篇

(1)最討厭的@字元

<span style="font-size:18px;">@hide</span>

@hide字元一般出現在源碼類或者方法的開頭注釋部分,表示這個方法或者類是在google提供的sdk中隱藏起來的,不能直接調用。要是想使用可以用反射,編譯源碼等方法。

(2)@link

<span style="font-size:18px;">@link</span>

@link字元是可以單獨使用如:@link sth 或者@link sth1#sth2。主要是用來產生javadoc檔案使用。當我們去掉這個字元是否會對編譯造成影響我還在實驗,稍後會貼上結果。

(3)@param

<span style="font-size:18px;">@param</span>

查看本欄目更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

@param出現的頻率最高,它也是javadoc也就是文本記錄的字元之一。主要是用來注釋以下方法中用到的參數的功能。

<span style="font-size:18px;">/** *@param context *@param attrs */Public DotView(Context context, Attribute attrs) {       super(context, attrs);       setFocusAbleInTouch(true);  }</span>

(4)@see

<span style="font-size:18px;">@see</span>

@see提示使用者相關的類或是函數資訊。

<span style="font-size:18px;">public abstract class MyBase {    protected abstract void myFunc();  }        class MyImpl extends MyBase {          /**    * @see MyBase#myFunc()    */  @Override  protected void myFunc() { .. }  }</span>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.