Some real-world examples of the Data structure "Stack"👇
A thread🧵
Stack is a LIFO (Last In First Out) data structure.
🔸A pile of books is an example of a stack. The last book kept on the pile will be removed first i.e LAST IN FIRST OUT (LIFO) data structure
🔸A pile of plates
🔸Stack of chairs
🔸Tower of Hanoi: Famous application of stack
🔸Activities (Screens) in your Android app are arranged in a stack (the back stack) in the order in which each activity is opened.
An example continued 👇
An email app might have one activity to show a list of new messages.
When the user selects a message, a new activity opens to view that message which is added to the back stack.
If the user presses the Back button, that new activity is finished and popped off the stack
🔸Women bangles - Women wear a bangle one by one and to pull the first one they have to first pull out the last one.
🔸Web browsers use the stack to keep track of the history of websites. If you click back then the previous site opens immediately.
🔸Call logs in mobiles use the stack (in which the recent call is on the top)
🔸When a company wants to reduce its workforce. Typically they follow "Last Hired First Fired"
🔸Function call uses the stack
🔸Matching of brackets by the compiler is also implemented using stack.
This is the end of the thread.
Real-life examples for other data structures coming soon. Be sure to give a follow to @meetjain74
After making m1 = null m1 becomes eligible for garbage collection. So when we call garbage collector the first time, Garbage Collector will call finalize() method on m1 before destroying it.
The finalize method will print "Finalise" here but in finalize method we are again referencing the same object by m which makes it no longer eligible for garbage collection. Hence the garbage collector will not destroy the object.
Confused about implementing data structures in real problems?
See some real-world examples of the Data structure "Array" today 👇
A thread 🧵
🔸A parking lot is an example of an array with each index of the array storing whether a car is present or not. Or it may be used for some other functionality.
Want to become an Android developer or start your journey with Android development but have not started yet?
Let me help you create your first Android app to kick off your Android journey.
Work with me to the end of the thread 🧵🧵
First, download Android Studio on your PC through this link and complete the setup and wait for all indexing and initial build to finish (might take time so keep patience) developer.android.com/studio
🔸Click on create new Project
🔸Select Empty Activity
🔸Click on next