www.fatihkabakci.com

Personal Website and Computer Science TUR EN

JAVA COLLECTION ARABIRIMI

Last update: 10/3/2014 6:29:00 PM

Yazan:Fatih KABAKCI

Java Collection Framework mimarisi içerisinde en tepede tanımlanmış bir interface olan Collection arabirimi, mimarinin tüm arabirimlerini oluşturmaktadır. Yani Collection Framework' un temelini Collection tutmaktadır. Collection, bir takım nesneleri depolamak ve kullanmak için kendini uygulayan bir çok sınıfa esnek metotlar sağlar. Collection Arabiriminin prototip formu aşağıdaki gibidir.
interface Collection <E>
Framework' un tum arabirimleri jenerik olduğu için Collection arabirimi de E jenerik tipi ile depolanacak nesnelerin tipini belirtir.

Java Collection Framework mimarisinin temelini oluşturan bu arabirimin metotları ise aşağıda verilmektedir.
  • boolean add(E e), bir collection' a E tipli nesne ekler. Eğer ekleme başarılı ise true döner.

  • boolean addAll(Collection c), bir collection' a elemanları E tipinden türemiş başka bir c collection' nın tüm elemanlarını ekler. İşlem başarılı ise true döner.

  • void clear(), collection' nın tüm elemanlarını kaldırır ve collection' ı sıfırlar.

  • boolean contains(Object o), collection içerisinde o nesnesinin varlığını araştırır. Şayet bulursa true döner.

  • boolean containsAll(Collection c), collection içerisinde, c collection' nın tüm elemanlarının varlığını denetler. Şayet tüm elemanlar collection içerisinde var ise true döner.

  • boolean isEmpty(), collection da hiç bir eleman yok ise true döner.

  • Iterator iterator(), collection' nın elemanlarını erişen bir iteratör döndürür.

  • boolean remove(Object o), collection' dan ilgili o nesnesini kaldırır.

  • boolean removeAll(Collection c), collection' dan c collection' nın elemanlarına eş değer tüm elemanları kaldırır.

  • boolean retainAll(Collection c), c collection' nın elemanlarına eş değer elememanların haricindeki tüm nesneleri kaldırır.

  • int size(), collection eleman sayısını döndürür.

  • Object[] toArray(), collection elemanlarını bir nesne dizisinde döndürür.

  • T[] toArray(T[] a), a dizisinin tipiyle eşleşen collection elemanlarını jenerik tipte bir dizi ile döndürür.

Collection arabirimi içerisinde eski ve yeni kodlara uyum çok önemli bir düzeyde sağlanmıştır. Bir collection toArray() sayesinde standart array kullanımı sunarken, iterator() sayesinde de yeni nesil java programlarına olan uyumu göstermektedir.
There has been no comment yet

Name:


Question/Comment
   Please verify the image




The Topics in Computer Science

Search this site for





 

Software & Algorithms

icon

In mathematics and computer science, an algorithm is a step-by-step procedure for calculations. Algorithms are used for calculation, data processing, and automated reasoning.

Programming Languages

icon

A programming language is a formal constructed language designed to communicate instructions to a machine, particularly a computer. It can be used to create programs to control the behavior of a machine. Java,C, C++,C#

Database

icon

A database is an organized collection of data. The data are typically organized to model aspects of reality in a way that supports processes requiring information.

Hardware

icon

Computer hardware is the collection of physical elements that constitutes a computer system. Computer hardware refers to the physical parts or components of a computer such as the monitor, memory, cpu.

Web Technologies

icon

Web development is a broad term for the work involved in developing a web site for the Internet or an intranet. Html,Css,JavaScript,ASP.Net,PHP are one of the most popular technologies. J2EE,Spring Boot, Servlet, JSP,JSF, ASP

Mobile Technologies

icon

Mobile application development is the process by which application software is developed for low-power handheld devices, such as personal digital assistants, enterprise digital assistants or mobile phones. J2ME

Network

icon

A computer network or data network is a telecommunications network that allows computers to exchange data. In computer networks, networked computing devices pass data to each other along data connections.

Operating Systems

icon

An operating system is software that manages computer hardware and software resources and provides common services for computer programs. The OS is an essential component of the system software in a computer system. Linux,Windows

Computer Science

icon

Computer science is the scientific and practical approach to computation and its applications.A computer scientist specializes in the theory of computation and the design of computational systems.