【发布时间】:2015-03-16 18:44:23
【问题描述】:
我从来没有学过Java,但我需要理解下面这段代码的含义,主要问题是花括号:
/**
* This Universe uses the full HashLife algorithm.
* Since this algorithm takes large steps, we have to
* change how we increment the generation counter, as
* well as how we construct the root object.
*/
public class HashLifeTreeUniverse extends TreeUniverse {
public void runStep() {
while (root.level < 3 ||
root.nw.population != root.nw.se.se.population ||
root.ne.population != root.ne.sw.sw.population ||
root.sw.population != root.sw.ne.ne.population ||
root.se.population != root.se.nw.nw.population)
root = root.expandUniverse() ;
double stepSize = Math.pow(2.0, root.level-2) ;
System.out.println("Taking a step of " + nf.format(stepSize)) ;
root = root.nextGeneration() ;
generationCount += stepSize ;
}
{
root = HashLifeTreeNode.create() ;
}
}
特别是在列表底部的这个声明:
{
root = HashLifeTreeNode.create() ;
}
貌似没有签名的方法,是什么意思?
提前谢谢你!
【问题讨论】:
标签: java