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. handsontable-developer guide-load and save

    不过handsontable不能用jquery取对象 var $$ = function(id) { return document.getElementById(id); }, container ...

  2. HttpServletRequest介绍

    HttpServletRequest对象代表客户端的请求,当客户端通过HTTP协议访问服务器时,HTTP请求头中的所有信息都封装在这个对象中,通过这个对象提供的方法,可以获得客户端请求的所有信息. 二 ...

  3. DotNetBar.MetroTilePanel 样式、加载数据、获取数据

    描述下:MetroTilePanel包含子集ItemContainer  子集下面又包含子集MetroTileItem  目前我用到的就是这三层 因为需求所以整个模块全部由代码实现 1.ItemCon ...

  4. aspnetPage分页控件

    项目里面有一个分页,刚好知道了aspnetPage分页控件,现在就把实现步骤和代码贴出来分享一下,如有错误欢迎指正. http://www.webdiyer.com  该控件原网址.里面文档 1.首先 ...

  5. C# 调用人脸识别 虹软ArcFace2.0实例

    虹软SDK推出了2.0版本,这个版本的所有API都集合在一个动态库里面,再通过引擎库调用,比1.2版本相对轻便了很多. 了解详情戳这里 小西瓜也迫不及待弄了一个新版本的C#实例,基于VS2013开发的 ...

  6. hibernate SQL Error: 8152, SQLState: 22001

    这种会出现字符串截断 数据库字段长度设置太小,改大即可.

  7. win32拖拽编程

    本文由作者邹启文授权网易云社区发布. 在邮箱大师PC版中,我们需要实现一个功能:账号和邮件夹拖拽排序. 准备 封装win32 API.我们使用到的API有, ImageList_Create.Imag ...

  8. CF553C Love Triangles

    题目链接 题意:给定n个点,给出一些边权为0/1的边,构造完全图,满足对于任何一个三元环,三条边权和为奇.求符合条件的完全图数量,对\(1e9+7\)取模. 分析:其实原题给定的边权是love/hat ...

  9. ADB模块源码分析(二)——adb server的启动

    1. ADB Server的启动 前面我们讲到adb模块的源码在system/core/adb下面,通过查看Android.mk文件我们了解到这个adb 模块回编译生成连个可执行文件adb.adbd, ...

  10. JAVA中Date类的使用

    一. Date类 Date类对象的创建: 1.创建一个当前时间的Date对象 //创建一个代表系统当前日期的Date对象 Date d = new Date(); 2.创建一个我们指定的时间的Date ...