• Post Reply Bookmark Topic Watch Topic
  • New Topic

array declaration  RSS feed

 
Rayt Leeop
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any difference between delcare an array using type and class name? for example;

public Person{

int[] student = new int[5];

Person[] workers=new Person[6];


I saw both of declaration but do not know the difference.
Many thanks
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rayt Leeop wrote:Is there any difference between delcare an array using type and class name? for example;

No difference, you can create array for int, double, chars primitives and for objects. In short you can create array of any data type.
 
Murtaza Lokhandwala
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah! The only difference in there default values.Class name contains default value 'null' while int contains '0'.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!