• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Assignments .PLS HLP ME !!!!!

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

can anyone pls tell me wheter the following declarations are allowed:-
1)double[][] d=new double[3][5];
double[] c=d;
2)double[][] d=new double[3][5];
double [][] a=d;
3)double[][] d;
double[] a=new double[2];
d={a,a}
4)double[][] d=new double[3][5];
double[] a=new double[3];
d=a;
double[] g=new double[15];
d=g;
Thx in advance

 
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The second statement in 1) won't compile because d is defined as a double array, and c is defined as a single array.
Changing to: double [][] c = d ; will compile.
Statements in 2) compile without problem (2-dimensional array being assigned to another 2-dimensional array).
The 3rd statement in 3) won't compile. First, the statement is missing the ";" at the end. However d={a,a} ; still gives a illegal start of expression error.
However, using a double[][] d = { a , a } ; after the first statement will compile without error. Why the compiler will not let you split the declaration and the initialization is beyond me. I would appreciate it if someone could let me know why!
Statements 3 and 5 in the 4) won't compile, becuase you're trying to assign two-dimensional arrays into variables that have been defined as single-dimensional arrays.
[This message has been edited by Joe McGuire (edited May 23, 2001).]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic