Data Structure Definition Java

What is Data Structure?

Data Structure in javaData Structure,

first of all lets break it down to pieces : Data and Structure.
What is a data? Googling on the internet said :

Philosophy “things that is probably known or assumed as facts, making the basis of reasoning or calculation”.
                    Computing “the quantities, characters, or symbols on which operations are performed by a computer, being stored and transmitted in the form of another electrical signals and recorded on magnetic, optical, or mechanical recording media

Continue reading Data Structure Definition Java

Java Collections

As you see from the last post, choices have methods such as the add() method, well if you don’t know… methods such as add() comes from a Framework in Java called Collections. Collections is a Framework (as I said) that provides the user an architecture that is used to store and manipulate a group of objects.
Not only add() method that you can do, you can do much more like : searching, insertion, sorting, deletion, manipulation etc… in Java Collections.

Here’s a list of what Collections provides :

  1. Deque
  2. List
  3. Set
  4. Queue

 Classes :

  1. ArrayList,
  2. LinkedList,
  3. HashSet,
  4. Treeset, etc…

What is a Framework in java?
Framework provides a readymade architecture that represents a set of classes and interface and it’s optional.

Here’s a list of methods that Collection provides :

  • public boolean add(Object element) :   this is  used to insert an element in this collection.
  • public boolean remove(Object element) :   the method s used to delete an element from this collection.
  • public boolean removeAll(Collection c)  :  this one is used to delete all the elements of specified collection from the invoking collection.
  • public int size()  :  will return the total number of elements in the collection.
  • public boolean contains(Object element) :   all it used is to search an element.
  • public Iterator iterator()   : this’ll returns an iterator.
  • public Object[] toArray()  :  will converts collection into array.
  • public boolean equals(Object element) : will  matches two collection.

well since I didn’t put all of it, I’m gonna say … ETC.

Iterator interface?
An Iterator interface will provides a facility for iterating the elements in forward direction only.

Here’s a list of methods in Iterator interface :

  1. public boolean hasNext() : it will returns true boolean if iterator has more elements.
  2. public object next() : it returns the element and moves the cursor pointer to the next element.
  3. public void remove() : it removes the last elements returned by the iterator. It is rarely used.

 Conclusions

  • Collections is a Framework (as I said) that provides the user an architecture that is used to store and manipulate a group of objects.
  • Framework provides a readymade architecture that represents a set of classes and interface and it’s optional.
  • An Iterator interface will provides a facility for iterating the elements in forward direction only.