Hey JohnnyR :-)
I have been working with this all day, but I'm still very confused. I understand your earlier suggestions in concept, but my coursebooks do not show me an example of using for with two variables. Let me explain in greater detail:
I need to create a constructor that takes a single argument of type String.
public myString(String args)
The constructor should create an array of char which is the same size as the constructors argument and assign it to test array (which is of type Char). Then your code should copy all the letters from the argument into the array referenced by test in the same order.
So I have think I have two variables, the String length of the argument (args) which could vary and the need to cast each String character to Char?
My example codes do not seem to touch on this for example (a very different example):
|
Code:
|
double[] hoursWorked = new double[52];
for (int i = 0; i < hoursWorked.length; i++)
{
hoursWorked[i] = 40.0;
} |
So I can see that test.length would return the size of the array so this might be appropriate in the for statement? But this (above) only deals with an array that has already been created and makes changes. I need to take a String agrument, convert each character to Char and then insert into the test array (suitable for Char).
Please if you can help, I would be so grateful. I'm confident that once I have cracked this, I can rocket on with my questions. But at the moment - I am totally lost! Totally.
All the best (and I have tried to PM as well)
FMJ.