Dear list,
There is one other problem I am getting which I
don't quite understand (a different one to the one I was asking about
before)
:The program is also a short one.
=======================================================================
=======================================================================
public class Tute9Q1 {
public static void main (String []
args)
{
double [] array = new double[100];
double [] y = new
double[200];
double value = 7.5;
for(int p = 0; p < 100; p++)
{
array[p] = value;
value += 2.5;
}//end of for loop
for (int p = 0; p < array.length;
p++)
{
y[p] = array[p];
}//End of for loop
y = array;
//putting the above assignment in, causes the
loop below not to work ie
//when I run the program, the loop below doesnt
produce any output.
//If I put the above line below the loop below,
then it works
// I don't understand.
for (int r = 100; r < y.length;
r++)
{
System.out.print("y[r]>" + y[r] +
" ");
} // end of for loop
System.out.println();
System.out.println();
System.out.print("y 51st element:" +
y[50]);
}//End of main method
}// End of class
========================================================================
========================================================================
The problem is when I put in the assignment statement ---
y = array;
that causes the loop below the assignment not to produce any
output.
And I don't quite understand why ?
Am I correct in suggesting what the statement y = array is actually about ? That y
then gets the same reference
as array ? That by using "y" and "array" we are referring to
the reference to the array object of these 2 arrays ?
But I don't understand why by putting the assignment statement
y = array ,where it is, causes the loop below it not
to work ?
Can you suggest what is wrong ?
---You are currently subscribed to jdjlist as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] |