Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Declaring an Object design

 
Anthony Smith
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public static final int[][] roleOrderRank =
{
{SUPER_USER, 1},
{COMPANY_DEVELOPER, 2},
{COMPANY_ADMINISTRATOR, 2},
{USER_ADMINISTRATOR, 3},
{CONTENT_ADMINISTRATOR, 4},
{VENDOR_USER, 4},};
There is my code. It is in a class that is bascially full on constants. I want to be able to reference that 2D array. I know I have to use 2 for loops
but, how do I make it stop iterating b4 it goes out of bounds? I thought about using another kind of object container, but I want one I can use w/o having to instantiate the class...
please help.
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arrays are objects. One attribute of an array is its length attribute. Therefore, you need to use that in your condition.
 
Anthony Smith
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that is exactly what I needed. However, could have declared the object using something besides an array? Can you declare a HashMap or some other object without trying to instantitating a class?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic