gpt4 book ai didi

java - java 程序卡住了......我想我没有正确处理 String 对象

转载 作者:行者123 更新时间:2023-12-01 17:32:57 24 4
gpt4 key购买 nike

我是 Java 新手,正在尝试编写一个程序..这是代码。在函数reduce中,当count = 14时,程序卡住了...请让我知道我做错了什么..

public static class MerkleReducer extends MapReduceBase
implements Reducer<LongWritable, Text, LongWritable, Text> {

static String[][] sarray = new String[5][14];
static int count = 0;

private void MerkleReducer() {
for (int i=0;i<5;i++)
for (int j=0; j<14;j++)
sarray[i][j] += "";
}

public void reduce(LongWritable key, Iterator<Text> values
OutputCollector<LongWritable, Text> output, Reporter reporter) throws IOException {

count++;
Text hashval = new Text();
while (values.hasNext()) {
hashval = values.next();
}
sarray[0][(int)key.get()] += hashval.toString();
if (count == 14) {
for (int i=1; i<5; i++) {
for (int j=0; j<7; j = j++) {
int k = 2 * j;
String hashv= new String();
if ("".equals(sarray[i-1][k])) {
break;
}
if ("".equals(sarray[i-1][k+1])) {
sarray[i][j] = sarray[i-1][k];
break;
}
hashv += sarray[i-1][k] + sarray[i-1][k+1];
sarray[i][j] += hashv;

}
}
output.collect(key, new Text(sarray[3][0]));

} else {
output.collect(key, new Text(hashval.toString()));
}

} }

最佳答案

j = j++ 表示j永远不会改变,它将采用j的当前值,增加j >,然后将旧值赋回j

关于java - java 程序卡住了......我想我没有正确处理 String 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9254075/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com