Creating a constructor with arrays and arguments
I'm having some problems again! I am trying to create a constructor with the following array requirements.
Firstly - I have created a private instance variable called test that is suitable for holding an array of characters.
private char test;
I am then asked to create a constructor that takes a single argument of type String. The constructor should create an array of char which is the same size as the constructors argument and assign it to test. Then the code should copy all the letters from the argument into the array referenced by test in the same order.
I get the error wrong type. This I understand. I need to cast the String argument to type char. But I only have examples of using CharAt(index), which will return only one character not all as Char.
public myString(String args)
this.test = args;
Can anyone let me know where and what I have done wrong.
All help gratefully accepted.
All the best - FMJ.