编译包含一些泛型的以下代码时出错:
public abstract class State<T extends HasAState<? extends State<T>>>{
protected T parent;
public void setParent(){ // It's been simplified for the sake of the question!
parent.removeState(this); // Error here!
this.parent = parent;
parent.addState(this); // Error here!
}
}
public interface HasAState<T extends State<? extends HasAState<T>>> {
public void addState(T state);
public void removeState(T state);
}
Run Code Online (Sandbox Code Playgroud)
错误是: The method removeState(capture#1-of ? extends State<T>) in the type HasAState<capture#1-of ? extends State<T>> is not applicable for the arguments (State<T>)
实际上我想要的是:class A implements …
我正在学习泡泡排序.而且我倾向于忘记每次的排序类型.所以我试图找到每种类型的逻辑含义,以便它有助于回忆排序的逻辑:
我无法理解为什么冒泡排序被命名为冒泡排序的确切含义?
所以今天我脑子里有了一个想法...而且我想听一些反馈.我有一个Java应用程序,需要每5分钟检查一个目录.简单而简单的应用程序需要每五分钟运行一次.
看起来像cronjob的一个很好的候选人,但我想知道...为什么不保持逻辑/时间在应用程序中像这样(显然简化):
public static void main(String[] args) {
while(true) { // repeatedly execute...
// do the work/job
Thread.sleep(600 * 1000); // make the thread sleep for 5 minutes
}
}
Run Code Online (Sandbox Code Playgroud)
我看到的一个重要缺点是" 一旦它开始,我们如何停止这个应用程序?删除它?
除了那个之外,还有其他重要的缺点吗?
我应该停止做白日梦而只是使用cron工作吗?
我有一个java文件有一个非常大的方法,它编译成功,但运行后抛出java.lang.ClassFormatError:类文件中的无效方法代码长度72521
我研究vm规范文件JVM将方法的最大大小限制为65536字节.JVM规范提到了这个限制
这有什么工作吗?