This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

array doubt  RSS feed

 
Vishal Hegde
Ranch Hand
Posts: 1078
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: 1078
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thankssssssssssss so muchhhhhhh
 
Campbell Ritchie
Marshal
Posts: 55687
163
  • 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
Posts: 21089
85
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
Boost this thread!