I know that my question is a bit bizarre but I can't wrap my head around it.
Subject:
I've a class and fields declared before constructor and I need constructor as well, say:
class Fields
{
private int field1;
Fields(int field1)
{
this.field1 = field1;
}
}
This one above makes sense to me. Now, the code below, I've seen that kind of code somewhere
class Fields
{
Fields(int field1)
{
//some code here
}
}
Question:
Why would someone need the second option without declaring fields outside a constructor?
Thanks!