So I know the thing about overriding "toString" to see what you want instead of the type, but in my case the overall picture is:
所以我知道覆盖“toString”以查看你想要的而不是类型的东西,但在我的情况下,整体情况是:
Project1:ClassA
uses Project2:ClassB
where I included Project2
into Project1
classpath and compilation works fine.But, the Project2:ClassB.toString()
prints project2.package.classC
instead of the classC elements of classB.
Project1:ClassA使用Project2:ClassB,其中我将Project2包含到Project1类路径中并且编译工作正常。但是,Project2:ClassB.toString()打印project2.package.classC而不是classB的classC元素。
Note, once I copy classB into project1, the printing works fine and I see the elements.
注意,一旦我将classB复制到project1,打印工作正常,我看到了元素。
Here is a snapshot of classB from project2 that I'm using in my current project1:
这是我在当前project1中使用的project2的classB快照:
package edu.cs;
public class FeatureWeightArrayWritable implements Writable {//classB
public int vectorSize;
public FeatureWeight[] vector; //classC = FeatureWeight
@Override
public String toString() {
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < this.vectorSize; i++)
buffer.append(vector[i].feature + " " + vector[i].weight);
// return buffer.toString();
return "Can't see this !!! I see edu.cs.FeatureWeight@32829 ";
}
}
and if you're suspicious about FeatureWeight
class, I also override its toString, but it should not be even used if I had the return message as above. Any clues?
如果你对FeatureWeight类有所怀疑,我也会覆盖它的toString,但是如果我有上面的返回消息则不应该使用它。有什么线索吗?
Here is how I read it:
我是这样读的:
Reader reader = new SequenceFile.Reader(fs, inputPath, conf);
Writable key = (Writable) reader.getKeyClass().newInstance();
FeatureWeightArrayWritable value = new FeatureWeightArrayWritable();
while (reader.next(key, value))
System.out.println("key:" + key.toString() + ", value:" + value.toString());
1 个解决方案
#1
0
Check your classpath, and make sure you don't have another copy (old class file, jar file, a 3rd project, etc) of FeatureWeightArrayWritable
laying around somewhere.
检查你的类路径,并确保你没有在某处放置FeatureWeightArrayWritable的另一个副本(旧类文件,jar文件,第三个项目等)。
#1
0
Check your classpath, and make sure you don't have another copy (old class file, jar file, a 3rd project, etc) of FeatureWeightArrayWritable
laying around somewhere.
检查你的类路径,并确保你没有在某处放置FeatureWeightArrayWritable的另一个副本(旧类文件,jar文件,第三个项目等)。