function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
@GM@GM 

what is the meaning of stack class in apex?

Is it implementation of stack concept in apex class or something else??

Best Answer chosen by Admin (Salesforce Developers) 
crop1645crop1645

Stacks are a computer science concept - see http://en.wikipedia.org/wiki/Stack_(abstract_data_type) 

 

You will need to implement a class that supports push and pop methods using APEX collection types, specifically, List. As this is an exercise for you, I leave it to you to figure out how to do this using the List type and various List instance methods

All Answers

Satish_SFDCSatish_SFDC
Do you mean Static Class.

Or if you mean the Stack Collection class, there is no such collection class in Apex. The only collection are Lists, Maps and Sets.

Can you provide the reference link so we can get the context?

Regards,
Satish Kumar
@GM@GM
3. Create a stack class in apex.

actually this is the question in my assignment.There is no reference link.
crop1645crop1645

Stacks are a computer science concept - see http://en.wikipedia.org/wiki/Stack_(abstract_data_type) 

 

You will need to implement a class that supports push and pop methods using APEX collection types, specifically, List. As this is an exercise for you, I leave it to you to figure out how to do this using the List type and various List instance methods

This was selected as the best answer
Richard CorfieldRichard Corfield
You have an interesting choice. A natural implementation of Stack would be to use a Linked List, as it's easy to access the ends and to allow it to change size. A simpler solution in Apex would be to wrap the List object and let the platform deal with the demands of the list changing size. If it's based on Java's ArrayList it should do quite well, and I've found some parts of Apex can be upset by linked lists. (It seems to have anti-recursion protection when serialising things, for example saving state in stateful batch processes.)