• Post Reply Bookmark Topic Watch Topic
  • New Topic

variables question  RSS feed

 
giorgo teler
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there ,

i am writing an application and i have so many variables (because of so many calculations) and i was wondering how can i put them on a class or how can i make them be all together but the class that i want to access them .I have read about ENUM is that right?or something similar .

thanks
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, giorgo!

I'm sorry, but your question is not very clear.

i have so many variables (because of so many calculations) and i was wondering how can i put them on a class


You define a class that groups together related quantities as member variables. For instance, if you're working with calculations on VOIP communication, you might have a class such as this:


If you're not familiar with member variables, they're covered in any Java textbook or tutorial.

I have read about ENUM is that right?


Hard to say for sure with so little detail about what you're trying to do or what trouble you're having, but I would guess not. An enum is for when you have a known, fixed set of objects that you want to name. For instance, you might define and enum of planets, with values Mercury, Venus, Earth, Mars, .... Again, you can get more details from a book or tutorial.

And of course, once you've studied the appropriate materials, if you still have questions, post them here.

 
giorgo teler
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello jeff and thanks for your answer,
i am familiar with memeber variables and also with Enum but maybe someone has to offer a different approach.

when you say

You define a class that groups together related quantities as member variables.

do you mean this ? sorry for my bad English.





what i have is this but i don't want to have it like that because it's huge.


All this are member variables Not local variables .

is there a way s that i don't have them in my class but still can use them ? I don want to have them in my class because it's becoming very big and hard to read,although they all fit together .
I don't know how should i express that on an other way sorry !

thanks again.
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
giorgo

If you have that many instance member variables, you will need to consider breaking your mammoth class into smaller ones. Also, do all of them need to be instance members? Could some be made local to a method instead?
 
giorgo teler
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
giorgo teler wrote:Hello jeff and thanks for your answer,
i am familiar with memeber variables and also with Enum but maybe someone has to offer a different approach.

when you say

You define a class that groups together related quantities as member variables.

do you mean this ? sorry for my bad English.





what i have is this but i don't want to have it like that because it's huge.


All this are member variables Not local variables .

is there a way s that i don't have them in my class but still can use them ? I don want to have them in my class because it's becoming very big and hard to read,although they all fit together .
I don't know how should i express that on an other way sorry !

thanks again.



if i made them static in a different class for example variables class ad all of them are public static ? have you ever done something like that ?Any ideas?
 
giorgo teler
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Boswell wrote:giorgo

If you have that many instance member variables, you will need to consider breaking your mammoth class into smaller ones. Also, do all of them need to be instance members? Could some be made local to a method instead?

No because i have to use them for other calculations again .
What i mean is i calculate the power of 2 in one method i i have variables for this method what ever comes in this method takes only this variables and so on ....so them i can use the methods in all the classes that i have .if you understand me ?
 
giorgo teler
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
giorgo teler wrote:
James Boswell wrote:giorgo

If you have that many instance member variables, you will need to consider breaking your mammoth class into smaller ones. Also, do all of them need to be instance members? Could some be made local to a method instead?

No because i have to use them for other calculations again .
What i mean is i calculate the power of 2 in one method i i have variables for this method what ever comes in this method takes only this variables and so on ....so them i can use the methods in all the classes that i have .if you understand me ?

The implementation is very bad i know that but i am in hurry i have to finish that until Sunday(i will but i don't like it like that way)!!

thanks again
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!