6.3. Scope of a Declaration

The scope of a declaration of a member m declared in or inherited by an interface type I (§9.1.4) is the entire body of I, including any nested type declarations.

interface I{
	class C{}
	static class D{}
}

The scope of a class's type parameter (§8.1.2) is the type parameter section of the class declaration, the type parameter section of any superclass or superinterface of the class declaration, and the class body.

The scope of an interface's type parameter (§9.1.2) is the type parameter section of the interface declaration, the type parameter section of any superinterface of the interface declaration, and the interface body.

interface IU<T>{ }
class CU<T>{}

public class main3<X extends Number> extends CU<X> implements IU<X> {

}

  

The scope of a constructor's type parameter (§8.8.4) is the entire declaration of the constructor, including the type parameter section, but excluding the constructor modifiers.

public class main3{

	public <A,B extends A> main3(){

	}

}

  

The scope of a local variable declaration in a block (§14.4) is the rest of the block in which the declaration appears, starting with its own initializer and including any further declarators to the right in the local variable declaration statement.

int a = 1,b = a;

  

The scope of a local variable declared in the ForInit part of a basic for statement (§14.14.1) includes all of the following:

  • Its own initializer

  • Any further declarators to the right in the ForInit part of the for statement

  • The Expression and ForUpdate parts of the for statement

  • The contained Statement

ForInit、ForInitializer与ForUpdate

The scope of a local variable declaration in a block (§14.4) is the rest of the block in which the declaration appears, starting with its own initializer and including any further declarators to the right in the local variable declaration statement.

class Test1 {
    static int x;
    public static void main(String[] args) {
        int x = x;
    }
}

This program causes a compile-time error because the initialization of x is within the scope of the declaration of x as a local variable, and the local variable x does not yet have a value and cannot be used.  

Scope of a Declaration的更多相关文章

  1. [No000077]打造自己的Eclipse

    下载官网的Eclipse IDE for Java EE Developers 在根目录下的eclipse.ini文件中添加"-Dfile.encoding=UTF-8", 作用: ...

  2. 【对象模型】C++模版的编译链接过程——编译器真的会检查所有tocken层面的错误么?

    模版(template)设计的初衷,是设计一种自动实例化机制,不需要使用者参与,编译器可根据使用者提供的模版参数再套用类的定义来实例化.所谓实例化,除了包含对于程序变量的实例化,即开辟空间并设置某些变 ...

  3. C++名字空间/C++命名空间

    0.序言 名字空间是C++提供的一种解决符号名字冲突的方法. 一个命令空间是一个作用域,在不同名字空间中命名相同的符号代表不同的实体. 通常,利用定义名字空间的办法,可以使模块划分更加方便,减少模块间 ...

  4. JAVASCRIPT的一些知识点梳理

    春节闲点,可以安心的梳理一下以前不是很清楚的东东.. 看的是以下几个URL: http://web.jobbole.com/82520/ http://blog.csdn.net/luoweifu/a ...

  5. W3C词汇和术语表

    以A字母开头的词汇 英文 中文 abstract module 抽象模组 access 访问.存取 access control 存取控制 access control information 存取控 ...

  6. “Clang” CFE Internals Manual---中文版---"Clang"C语言前端内部手册

    原文地址:http://clang.llvm.org/docs/InternalsManual.html 译者:史宁宁(snsn1984) "Clang"C语言前端内部手册 简介 ...

  7. The Go Programming Language. Notes.

    Contents Tutorial Hello, World Command-Line Arguments Finding Duplicate Lines A Web Server Loose End ...

  8. 如何看破真假美猴王 ? --java中的Shadowing和Obscuring

    故事背景 <西游记>第五十七回:唐僧因悟空又打死拦路强盗,再次把他撵走.六耳猕猴精趁机变作悟空模样,抢走行李关文,又把小妖变作唐僧.八戒.沙僧模样,欲上西天骗取真经.真假二悟空从天上杀到地 ...

  9. 前端与编译原理——用JS写一个JS解释器

    说起编译原理,印象往往只停留在本科时那些枯燥的课程和晦涩的概念.作为前端开发者,编译原理似乎离我们很远,对它的理解很可能仅仅局限于"抽象语法树(AST)".但这仅仅是个开头而已.编 ...

随机推荐

  1. javascript与java的相互调用,纯java的javascript引擎rhino(转载)

    1.下载Rhino安装包,下载地址:官网http://www.mozilla.org/rhino. 2.rhino环境配置,把解压出来的js.jar文件加入到系统的环境变量classpath 3.在命 ...

  2. shell 脚本 查看班上同学的网络状态

    #!/bin/base # a=192.168.100. //定义变量 c=('王浩' '谢云生' '黄科杨' '何星宇' '张宸兵' '胡燕' '刘桃') //定义数组 for b in {101. ...

  3. nginxのerror_logはformat指定できない.

    備忘録です. http://toshitanian.hatenablog.com/entry/2013/10/25/023838 2013-10-25 nginxのerror_logはformat指定 ...

  4. [翻译] Writing Property Editors 编写属性编辑器

    Writing Property Editors 编写属性编辑器   When you select a component in the designer its properties are di ...

  5. 一个hql语句

    在hql语句里面,in的使用方法比较特别. from DomesticCat cat where cat.name in ( 'Foo', 'Bar', 'Baz' ) in后面是一个list,我写的 ...

  6. Solr相似度算法三:DRFSimilarity

    该Similarity 实现了  divergence from randomness (偏离随机性)框架,这是一种基于同名概率模型的相似度模型. 该 similarity有以下配置选项: basic ...

  7. Js 事件详解

    1.事件流 1.1 事件流 描述的是在页面中接受事件的顺序 1.2 事件冒泡 由最具体的元素接收,然后逐级向上传播最不具体的元素的节点(文档) 1.3 事件捕获 最不具体的节点先接收事件,而最具体的节 ...

  8. php foreach 遍历细节探讨

    foreach 也是正常的语法循环结构,可以有 break 和 continue 等操作 遍历过程中值变量传递默认是值传递 输出结果为: 遍历过程中值变量可以认为设定为引用传递:foreach($数组 ...

  9. RabbitMq初探——发布与订阅

    publish and subscribe 前言 前面的例子 我们都是用到的都是消息单一消费,即一条消息被单个消费者消费.像微博系统的消息推送,是一条消息推送给所有订阅到该频道的用户. 这里我们就需要 ...

  10. python--生成器,生成器推导式, yield from

    一.生成器 生成器的本质就是迭代器,它一个一个的创建对象. 在python中有三种方式获取生成器: 1.通过生成器函数 2.通过各种推导式来实现生成器 3.通过数据的类型转换也可以获取生成器 二.生成 ...