Java 的 annotation

  • 以@开头 比如@Override.
  • 不改变complied program的action
  • annotation不完全是comments 能够改变一段代码compile的方式

下面这段代码因为base class里没有display(int x), 所以是用@Override就会报错。

/* Java program to demonstrate that annotations are
not barely comments (This program throws compiler
error because we have mentioned override, but not
overridden, we haver overloaded display) */
class Base
{
public void display()
{
System.out.println("Base display()");
}
}
class Derived extends Base
{
@Override
public void display(int x)
{
System.out.println("Derived display(int )");
} public static void main(String args[])
{
Derived obj = new Derived();
obj.display();
}
}

Java Binary Tree DFS的更多相关文章

  1. leetcode 111 Minimum Depth of Binary Tree(DFS)

    Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...

  2. leetcode 104 Maximum Depth of Binary Tree(DFS)

    Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...

  3. leetcode 110 Balanced Binary Tree(DFS)

    Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary ...

  4. [Leetcode][JAVA] Binary Tree Level Order Traversal

    Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, ...

  5. [Leetcode][JAVA] Binary Tree Maximum Path Sum

    Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. ...

  6. [LeetCode] Maximum Depth of Binary Tree dfs,深度搜索

    Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...

  7. Java for LeetCode 199 Binary Tree Right Side View

    Given a binary tree, imagine yourself standing on the right side of it, return the values of the nod ...

  8. LeetCode算法题-Average of Levels in Binary Tree(Java实现)

    这是悦乐书的第277次更新,第293篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第145题(顺位题号是637).给定一个非空二叉树,以数组的形式返回每一层节点值之和的平 ...

  9. Java for LeetCode 124 Binary Tree Maximum Path Sum

    Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. ...

随机推荐

  1. FLTK 1.3.3 MinGW 4.9.1 Configuration 配置

    Download FLTK 1.3.3 Download CMake 3.2.0 Start CMake 3.2.0, fill the source and destination: source: ...

  2. Intent学习笔记

    Intent首先字面意思大概是意图.负责activity之间或者,activity与service等(我只知道这么点)之间信息的传递.就跟快递员起的作用差不多(我这这么理解),由一下六部分组成: Co ...

  3. android之发送短信程序

    首先改写activity_main.xml文件 代码如下: <LinearLayout xmlns:android="http://schemas.android.com/apk/re ...

  4. Everything文件名实时搜索||解决局域网文件共享问题

    内容概要:Everything中文版下载地址及使用.用Everything轻松解决局域网文件共享问题.Everything语言设置问题 另:Everything只支持NTFS格式的磁盘(工作原理的缘故 ...

  5. 前端编码风格规范(3)—— JavaScript 规范

    JavaScript 规范 全局命名空间污染与 IIFE 总是将代码包裹成一个 IIFE(Immediately-Invoked Function Expression),用以创建独立隔绝的定义域.这 ...

  6. windows7下使用telnet

    需要打开windows功能,telnet客户端. 在命令行里输入Telnet open www.qq.com 80 连接成功后会进入一个空界面,之前命令行窗口里的字符还在,光标却移动到最起始. 这是很 ...

  7. [学点经济]什么是SDR [the IMF's Special Drawing Rights (SDR) basket of currencies]

    思考题: 1.什么是SDR?能否用通俗的语言说明. 2.加入SDR对中国有什么好处?能否举1-3个实例说明. 3.加入SDR有没有坏处?能否举例说明. 4.近期关于SDR的新闻有哪些?中国外国的例子都 ...

  8. HTTP 笔记与总结(9)分块传输、持久链接 与 反向 ajax(comet / server push / 服务器推技术)

    反向 ajax 又叫 comet / server push / 服务器推技术 应用范围:网页聊天服务器,例如新浪微博在线聊天.google mail 网页聊天 原理:一般而言,HTTP 协议的特点是 ...

  9. mysql默认字符集修改

    (1) 最简单的修改方法,就是修改mysql的my.ini文件中的字符集键值,添加 [mysql] default-character-set = utf8 [mysqld] character_se ...

  10. Fortran并行计算的一些例子

    以下例子来自https://computing.llnl.gov/tutorials/openMP/exercise.html网站 一.打印线程(Hello world) C************* ...