Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

array

 
jp staff
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I make An array if I want to make an instance of a class, in other words
class BB{
private int n;
public calculations();
}
\\\\\\\\Here is the main driver
How can I set up an array of 25 b classes, would it be
BB bk[]=new BB[25]
How would I beable to access each method from the main:
bk[i].calculations();
Thanks for your help
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to instantiate each of your array elements if you will be using them.
for(int i = 0; i< bk.length; i++)
bk[i] = new (What ever yoeu constructor is expecting)
}
bk[i].calculations();
Bosun



 
I can't take it! You are too smart for me! Here is the tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!