This is perfectly OK in Java.
public class InitTest
{
int test=0;
InitTestClass testClass=new InitTestClass(test);
public static void main(String args[])
{
InitTest test=new InitTest();
}
}
class InitTestClass
{
int test=0;
InitTestClass(int test)
{
this.test=test;
}
}
The following code, however, is not (C#).
namespace InitTest
{
class Program
{
int test = 0;
// Error
InitTestClass testClass = new InitTestClass(test);
static void Main(string[] args)
{
}
}
class InitTestClass
{
int test = 0;
public InitTestClass(int test)
{
this.test = test;
}
}
}