NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class ArrayListOrnek
{
/*
Generic Class : Belli Parametreler Gore
Kendi Icinde Calisan Methodların Dönüş Türleri
Ve Aldığı Parametre Türleri Değişen Sınıflara
Generic Sınıf Denir
*/

public static void main(String[] args)
{
ArrayList<String> al = new ArrayList<>();

// ArrayList Eleman Sayısı
int cnt = al.size();

// Eleman Ekleme :: Listenin Sonuna
al.add("Emir");
al.add("Sercan");

// Eleman Ekleme :: IStedigin Index'e
al.add(1,"Efe");

// ArrayList'i Ekrana Bastır
System.out.println(al);

// ArrayList'te Bir Elemana Erişme
String ad = al.get(0); // ar[0]
System.out.println("Ilk Eleman : "+ad);
System.out.println("Son Eleman : "+al.get(al.size() - 1));

// ar[11] = 53;
al.set(2, "Ezgi");

boolean isExists = al.contains("Emir");

// Array List Boş Mu
boolean isEmpty = al.isEmpty();

// ArrayList'i Temizle
al.clear();
System.out.println(al.size());

// ArrayList'teki Bir Elemanı Index'e Gore Sil
//al.remove(0);

// ArrayList'teki Bir Elemanı Değere Göre Sil
al.remove("Efe");

ArrayList<Integer> al2 = new ArrayList<>();
al2.add(5);
al2.add(8);
al2.add(49);
al2.add(2);
al2.add(101);

// ArrayList'in Bir Bolumunu Baska Bir
// Liste Olarak Al

List<Integer> subList = al2.subList(0, 3);
System.out.println(al2);
System.out.println(subList);

ArrayList<Integer> numbers = new ArrayList<>();
numbers.add(456);
numbers.add(145);
numbers.add(999);

// sublistteki her sayiyi, numbers'a ekle
numbers.addAll(subList);
System.out.println(numbers);

// al2deki her sayiyi, numbers'tan cikar
numbers.removeAll(al2);

System.out.println(numbers);

// ArrayListteki Elemanları Karıştır
Collections.shuffle(numbers);
// ArrayListteki Elemanları Sırala
Collections.sort(numbers); // 0-9, A-Z
// ArrayListteki Elemanların Sıralamasını Terse Çevi
Collections.reverse(numbers);

// Bir Elemanın Index Değerini Öğren (0-> N)
int fNdx = numbers.indexOf(834);
int lNdx = numbers.lastIndexOf(834);

ArrayList<Kisi> kisiler = new ArrayList<>();
/* ÖZEL SORTING YONTEMI
Comparator<Kisi> kiyaslamaMethodu =
new Comparator<Kisi>()
{
public int compare(Kisi o1, Kisi o2)
{
if (o1.dogumYili < o2.dogumYili)
return 1;
else if (o1.dogumYili == o2.dogumYili)
return 0;
else
return 2;
}
};

Collections.sort(kisiler, kiyaslamaMethodu); */
}
}

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.