Connecting Tech Pros Worldwide Help | Site Map

Arrays T_T

Newbie
 
Join Date: Feb 2009
Posts: 2
#1: Feb 21 '09
I have a global variable, something like this:

Expand|Select|Wrap|Line Numbers
  1. public class Comisiones {
  2.  
  3.     double monto,max=0,min=0
Now... I have a Comisiones array, declared in the main, something like this:

Expand|Select|Wrap|Line Numbers
  1.     public static void main(String[] args) {
  2.         Comisiones x[]=new Comisiones[20];
That means each Comisiones object will have its own monto, max, and min variables... but what if I want to use these variables for all the array (for example min being the minimal price for all the objects)... what do I do to solve this?

Thanks in advance n.n!
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Feb 21 '09

re: Arrays T_T


Quote:

Originally Posted by KirbyIwaki View Post

That means each Comisiones object will have its own monto, max, and min variables... but what if I want to use these variables for all the array (for example min being the minimal price for all the objects)... what do I do to solve this?

Either lift those min and max variables out of the class and store them once somewhere else or leave them in that class and make them static.

kind regards,

Jos
Newbie
 
Join Date: Feb 2009
Posts: 2
#3: Feb 21 '09

re: Arrays T_T


Quote:

Originally Posted by JosAH View Post

Either lift those min and max variables out of the class and store them once somewhere else or leave them in that class and make them static.

kind regards,

Jos

I static-ized them, thanks n.n!
Reply

Tags
array, arrays, global variable, objetcs array