这是我的下载代码:
var mimeType = this.getMime(obj);
var ab = this.base64ToArrayBuffer(obj[key]);
var blob = new Blob([ab.buffer], {
type : mimeType
});
var result = this.bintostring(blob);
var url = window.URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = result.filename;
a.target = '_blank';
a.click();
window.URL.revokeObjectURL(url);
Run Code Online (Sandbox Code Playgroud)
在调试过程中,我没有看到任何异常.
我编写了一个泛型类,下面是该类的构造函数.我想做这样的事情就像写在线一样
elements = (E[])new Object[size]
Run Code Online (Sandbox Code Playgroud)
因为我不知道运行时的泛型类型因此会抛出异常.
public class Stack<E> implements IStack<E> {
protected E[] elements = null;
protected int top = -1;
protected int size= 0;
private static final int DEFAULT_CAPACITY = 10;
public Stack(){
this(DEFAULT_CAPACITY);
}
public Stack(int size){
if(size <0){
throw new IllegalArgumentException("Initial capacity cannot be negative or zero");
}
ArrayList<Integer> ar = new ArrayList<Integer>();
elements = (E[])new Object[size];
}
}
Run Code Online (Sandbox Code Playgroud)
有什么方法可以解决这些问题吗?E的声明是
protected E[] elements = null;
Run Code Online (Sandbox Code Playgroud)
这就是我试图打电话的方式
Random ran = new Random();
Stack<Integer> st = new Stack<Integer>(); …Run Code Online (Sandbox Code Playgroud)