Here is how my constructor has been defined
public One (int [] a, int [] b)
{
A = a;
B = b;
C = new int [a.length + b.length];
}
This is how I am creating a object for this:
One A = new One ([1,3,5], [1,5,3]);
I am getting multiple errors for this , like the constructor (int,int,int,int,int,int) is not defined and syntax error on tokens,delete these tokens.
Can someone please tell me where am i going wrong ? Thanks
This is not how you create an array in java. You need to use it like this: –
new int[]creates an integer array object.{1, 3, 5}initializes the array inline.As a side note, you should declare your variable starting with lowercase letter. In your code, your instance array reference should be
ainstead ofA. And usethis.ato access it to avoid name conflict between local and instance variable.