-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListelemeOrnek.java
More file actions
66 lines (45 loc) · 1.44 KB
/
ListelemeOrnek.java
File metadata and controls
66 lines (45 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package subat24;
import java.util.ArrayList;
import java.util.Scanner;
import javax.print.attribute.Size2DSyntax;
public class ListelemeOrnek {
public static void main(String[] args) {
Scanner giris = new Scanner(System.in);
ArrayList<String> ad = new ArrayList<String>();
System.out.println(ad);
//Listeye boş kısma ekleme
ad.add("Ali");
System.out.println(ad);
ad.add("Kerem");
System.out.println(ad);
//Listedeki elemanı değiştirme
ad.set(0, "Mehmet");
System.out.println(ad);
//Listenin herhangi bir indexine eleman ekleme
// ad.add(index,eklenecek isim)
//Listenin ilk eleman yerine ekler, diğerlerini sağa kaydırır
ad.add(0,"Cem");
//Listenin sonuna ekleme
ad.add(ad.size(),"Kemal");
System.out.println(ad);
System.out.println("İsim ara: ");
String arananAd = giris.next();
for (int i = 0; i < ad.size(); i++) {
String sorgulananAd = ad.get(i);
if (sorgulananAd.equalsIgnoreCase(arananAd)) {
System.out.println("İsim bulundu");
}
else System.out.println("İsim bulunamadı");
return;
}
/*Scanner giris = new Scanner(System.in);
ArrayList<String> ad = new ArrayList<String>();
System.out.println("Kaç kişi girilecek ? ");
byte ks = giris.nextByte();
for (int i = 0; i < ks; i++) {
System.out.println(i+1+".Kişiyi girin");
}
System.out.println(ad);
*/
}
}