Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

array doubt

 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class Demo
{

public static void main(String args[])
int a[]=new int[2];
}


not how many object is being created for an array int a is it 2 objects?? or 1 object??
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishal,
array is just a container and here it the case of array of integers. And no objects whatsoever involved in this.
Please check few tutorials.
 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thankssssssssssss so muchhhhhhh
 
Campbell Ritchie
Sheriff
Posts: 48921
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Balu Sadhasivam wrote:Vishal,
array is just a container and here it the case of array of integers. And no objects whatsoever involved in this.
Please check few tutorials.
I think you are mistaken there.
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree. Arrays are objects themselves as well.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Technically, they're objects. From the rest of Java-style OOP, though... meh. java.util.Arrays and java.lang.System's arraycopy (yay, consistency) shouldn't be necessary, and I've never really understood it--why did they do it like that?
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

yep right .. thanks for the correction..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic