小编die*_*and的帖子

Java是否支持内部/本地/子方法?

这是我的代码.

public class SubFunction {
    private String drawTribleX(){
        return trible("X");
    }
    private String trible(String t){
        return t + t + t;
    }
    public static void main(String[] args){
        SubFunction o = new SubFunction();
        System.out.println(o.drawTribleX());
    }
}
Run Code Online (Sandbox Code Playgroud)

我可以这样做吗?

public class SubFunction {
    private String drawTribleX(){
        // *** move trible(t) inside drawTribleX() ***
        private String trible(String t){
            return t + t + t;
        }
        return trible("X");
    }
    public static void main(String[] args){
        SubFunction o = new SubFunction();
        System.out.println(o.drawTribleX());
    }
}
Run Code Online (Sandbox Code Playgroud)

谢谢.

java methods

49
推荐指数
2
解决办法
7万
查看次数

定义函数原型和类属性有什么区别?

按照我的代码,
Apple按原型定义功能.
香蕉是通过类属性定义函数.

var Apple = function(){}
Apple.prototype.say = function(){
    console.debug('HelloWorld');
}
var Banana = function(){
    this.say = function(){
        console.debug('HelloWorld');
    }
}

var a = new Apple();
var b = new Banana();

a.say();
b.say();
Run Code Online (Sandbox Code Playgroud)

这些不同吗?

javascript prototype

44
推荐指数
1
解决办法
5713
查看次数

我可以用Javascript做SendKeys吗?

SendKeys是将键击发送到应用程序的方法.
我可以在Javascript中执行此操作,在浏览器中发送按键吗?

参考:http :
//msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx

javascript sendkeys

17
推荐指数
1
解决办法
7万
查看次数

如何知道android中的内存大小?

这是我的代码,

private String memSize(String path){
    StatFs stat = new StatFs(path);
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    long freeBlocks = stat.getFreeBlocks();
    long countBlocks = stat.getBlockCount();
    String fileSize = Formatter.formatFileSize(this, availableBlocks * blockSize);
    String maxSize = Formatter.formatFileSize(this, countBlocks * blockSize);

    String info = path.toString()
                    + "\nblockSize : " + Long.toString(blockSize)
                    + "\navailableBlocks : " + Long.toString(availableBlocks)
                    + "\nfreeBlocks : " + Long.toString(freeBlocks)
                    + "\nreservedBlocks : " + Long.toString(freeBlocks - availableBlocks)
                    + "\ncountBlocks : " + Long.toString(countBlocks)
                    + "\nspace : " …
Run Code Online (Sandbox Code Playgroud)

storage android

7
推荐指数
1
解决办法
8152
查看次数

在ExtJS中,如何在事件发生时突然解除绑定?

目标是仅在第一次点击时显示警告框.

Ext.getCmp('myBtn').on('click', function(){
    alert('Alert this message only in first click.');
    Ext.getCmp('myBtn').un('click', this); // my attempt, still not work
})
Run Code Online (Sandbox Code Playgroud)

谢谢.

extjs event-handling

6
推荐指数
3
解决办法
6314
查看次数