I was following a tutorial and got incredibly confused when this technique was used, can anyone tell me what this is called and why this would be implemented? The following is an example:
Class Main:
package test;
public class Main {
//happens right here
public Test testMethod() {
Test test = new Test();
test.setSomeVariable(2);
return null;
}
}
Class Test:
package test;
public class Test {
private int someVariable = 2;
public int getSomeVariable() {
return someVariable;
}
public void setSomeVariable(int amount) {
someVariable = amount;
}
}
Essentially there is a call to the class in the same manner a method is used. It's not a constructor, as there is a method declaration following it.