I'm new to java. I'm facing a strange problem.
Here I have 2 folders in the project for main and for test
[![enter image description here][1]][1]
I defined public static variable in class in trident.functions
, then used it in another class in entities
by taking object form class, here everything is OK and variable is read well as it holds a number due to an equation I wrote, then stored result in this variable.
Problem with me in test folder. When I maven code I got failure with test classes when I debugged code I found that variable that I defined before hold zero not number, why this variable not read number, however it worked well before with other classes in main?
public class Vector implements Function {
public static double num;
String words[]={"asd","wer","dfdf","rttyy"}
public Values getValues(Tweet tweet, String[] words){
//this part of the code of the variable i defined
for(String w:words)
{
items.add(w);
}
num = items.size();
}
public Spar normVector(Spar vector) {
double z = vector.getnum();
vector = //some calculations on z ;
return vector;
}
}
another class
public class Spar {
public double getnum() {
double x=Vector.num;
return x;
}
}
Test class
public class VectorTest {
Vector vb;
public VectorBuilderTest(String vbr) {
super(vbr);
vb = new VectorBuilder();
}
public void testNormalizeVector() {
Spar sp = new Spar(values);
Spar normalized = vb.normVector(sp);
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…