小编use*_*113的帖子

Java异常try-catch异常与IOException

即使try块实际上没有抛出任何异常,下面的代码也可以编译好.

public static void main(String[] args)  {
    try {} 
    catch (Exception e) {} // compiles ok
}
Run Code Online (Sandbox Code Playgroud)

但是如果使用Exception的子类替换catch,则代码将无法编译.

public static void main(String[] args)  {
    try {} 
    catch (IOException e) {} // won't compile. 
}
Run Code Online (Sandbox Code Playgroud)

编译器错误是:IOException的无法访问的catch块.永远不会从try语句主体抛出此异常.

当异常和IOException都被检查异常时,为什么会出现这种情况?我正在使用Java 7.

java exception

5
推荐指数
1
解决办法
6015
查看次数

在bash脚本if语句中使用$ {}

bash脚本新手.在bash脚本的开头,初始化变量

silent_install=true
Run Code Online (Sandbox Code Playgroud)

然后在脚本中以下面两种方式使用此变量

if [ -z "$silent_install" ]; then
Run Code Online (Sandbox Code Playgroud)

if [ -z ${silent_install} ]; then
Run Code Online (Sandbox Code Playgroud)

这2个用法有什么区别?

unix bash

2
推荐指数
1
解决办法
74
查看次数

ExtJS 中组件被销毁后引用变量会发生什么?

ExtJS 新手。我有以下代码。

var comp;
console.log('comp is - ' + comp);
comp = Ext.create('Ext.Component', {
    listeners : {
        beforedestroy : function(comp) {
            console.log('beforedestroy .. ');
        },
        destroy : function(comp) {
            console.log('destroy .. ');
        }
    }
});
console.log('comp is - ' + comp);
console.log('comp id is - ' + comp.getId());
comp.destroy();
console.log('comp is - ' + comp);
console.log('comp id is - ' + comp.getId());
Run Code Online (Sandbox Code Playgroud)

chrome 的控制台输出是

comp is - undefined
comp is - [object Object]
comp id is - component-1009
beforedestroy .. …
Run Code Online (Sandbox Code Playgroud)

javascript extjs

0
推荐指数
1
解决办法
851
查看次数

标签 统计

bash ×1

exception ×1

extjs ×1

java ×1

javascript ×1

unix ×1