我有以下代码,除了命令行参数,每次我写"Insertion"它不会进入if语句所以输出将是"Algorithm not found. Use: [ Insertion | Merge ]"
public static void main(String[] args) throws IOException, InsertionAndMergeException, Exception {
if( args.length < 2 ) {
System.out.println("Use: <path> <algorithm> ");
System.exit(1);
}
if(args[1] == "Insertion" || args[1] == "Merge"){
testWithComparisonFunction(args[0], args[1], new RecordComparatorIntField());
}else
System.out.println("Algorithm not found. Use: [ Insertion | Merge ]");
}
Run Code Online (Sandbox Code Playgroud)
在命令行中我打字这个,我做错了什么?
java insertionandmergeusagejava/InsertionAndMer
geUsage "/home/zenoraiser/Scrivania/Università/Secondo Anno/Algoritmi/1718/LAB/Progetto/Integers.txt" "Insertion"
Run Code Online (Sandbox Code Playgroud) 我已经检查过像这样的其他问题,但似乎我并不总是创建一个新的迭代器来检查始终相同的对象。
这是代码
Iterator<Map.Entry<Node, Float>> it = graph.nodeNeighboursIterator(e);
System.out.println("extracted node "+ e.getLabel() + " number of neighbours "+ e.sizeNeighbours());
while(it.hasNext()) {
System.out.print(i + " " + e.getLabel() + " " + it +"-");
i++;
}
Run Code Online (Sandbox Code Playgroud)
该方法graph.nodeNeighboursIterator执行此操作
public Iterator<Map.Entry<Node, Float>> nodeNeighboursIterator(Node n) {
return this.graph_weighted.get(n).entrySet().iterator();
}
Run Code Online (Sandbox Code Playgroud)
打印System.out.println("extracted node "+ e.getLabel() + " number of neighbours "+ e.sizeNeighbours());出正确数量的邻居,但循环仍然没有结束他的循环,你对此有何看法?