0

My cousin told me not to use too much integers because larger no of integers take more space! i don't know what this space refers to, can anyone tell me?

11th Sep 2016, 11:40 AM
Ali Haider
Ali Haider - avatar
2 ответов
+ 2
They was likely refering to memory. Creating more and more of any variable will consume more memory, as that memory has to be allocated to that variable. This is not a bad thing. Bad things happen when you get memory leaks, which is memory which hasn't been freed up manually, usually only an issue with dynamic variables. As for the number of ints (or any variables for that matter), that you use in your program, do not worry about it at all; use as many as you like. When you start writing larger programs, you can always come back to refactor any code that you have done, such as removing any unnecessary variables. The memory that variables consume are as small as bytes, you have nothing to worry about at the moment.
11th Sep 2016, 1:03 PM
Cohen Creber
Cohen Creber - avatar
0
you can use the as per your requirements by using heap data type
12th Sep 2016, 6:15 AM
Mohd Shahrukh
Mohd Shahrukh - avatar