Hi !

To improve my java programming skills i like to write a really fancy fib. nr. calculator. Did it in C using memory allocation methods and hot to 1M digits in ~10min. So something like Step-Up challenge.


The only thing as far as i can see limits my progress is knowledge hot to create "structure" like class in java that i can use memory allocation on.

class DigitData {
public a;
public a;
public c;
}


class WithMainMethod {

/*
How i can allocate array of classes DigitData? 
How to do it by progressive allocation?
How to do it in way that the allocated data could be easy reachable by CPU? Im not sure what im talking about but how to do it in way that CPU will likely cache memory. 

But mainly how to lay in out as a code that does minimum? 
*/
}


Thank you in advance!

There are no direct connections to memory usage in java. The JVM takes care of it.

How i can allocate array of classes DigitData

Define the array and then in a loop, fill the array with instances of the class.

Thank you for a reply!

It sure gave me a clue how to achieve what i want ... array of classes.


The part about defining array i did:

DigitData[] digit = new DigitData[num];

How can i do a instance part?

How can i initialize the each 'digit' ?


Thank you in advance!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.