This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Collection; | |
import java.util.*; | |
public class HashSetDemo { | |
public static void main(String args[]){ | |
Set<String> set = new HashSet<>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Collection; | |
import java.util.*; | |
public class HashSetDemo2 { | |
public static void main(String args[]){ | |
Set<String> set1 = new HashSet<>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Collection; | |
import java.util.*; | |
public class LinkedHashSetDemo { | |
public static void main(String args[]){ | |
Set<String> set = new LinkedHashSet<>(); | |
set.add("London"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person { | |
String isim; | |
int yas; | |
public Person(String isim, int yas){ | |
this.isim = isim; | |
this.yas = yas; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Comparator; | |
public class PersonComparator implements Comparator<Person> { | |
@Override | |
public int compare(Person o1, Person o2) { | |
return o1.yas > o2.yas ? 1 : -1; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestComparator { | |
public static void main(String args[]){ | |
Person p1 = new Person("Meric",25); | |
Person p2 = new Person("Ali",15); | |
Person older = older(p1,p2, new PersonComparator()); | |
System.out.println("Yasi buyuk olan person :" + older.isim); // Meric |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class TestArrayAndLinkedList { | |
public static void main(String[] args) { | |
List<Integer> arrayList = new ArrayList<>(); | |
arrayList.add(1); | |
arrayList.add(2); | |
arrayList.add(3); | |
arrayList.add(1); | |
arrayList.add(4); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.nio.file.*; | |
import java.nio.file.attribute.*; | |
import static java.nio.file.FileVisitOption.*; | |
import java.util.*; | |
public class Find { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.nio.file.*; | |
import java.nio.file.attribute.BasicFileAttributes; | |
import static java.nio.file.FileVisitResult.*; | |
public class PathDemo extends SimpleFileVisitor <Path> | |
{ | |
@Override | |
public FileVisitResult visitFile(Path file, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PassByReference { | |
private String value = "First Value"; | |
public String getValue() { | |
return value; | |
} | |
public void setValue(String value) { | |
this.value = value; | |
} |
OlderNewer