LinkedList
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
|
||||
*/
|
||||
package testhashcode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class TestHashCode {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// TODO code application logic here
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package testhashcode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
import java.util.*;
|
||||
|
||||
public class TestHashSet {
|
||||
public static void main(String[] args) {
|
||||
// Create a hash set
|
||||
Set<String> set = new HashSet<>();
|
||||
|
||||
// Add strings to the set
|
||||
set.add("London");
|
||||
set.add("Paris");
|
||||
set.add("New York");
|
||||
set.add("San Francisco");
|
||||
set.add("Beijing");
|
||||
set.add("New York");
|
||||
set.
|
||||
|
||||
System.out.println(set);
|
||||
|
||||
// Display the elements in the hash set
|
||||
for (String s: set) {
|
||||
System.out.print(s.toUpperCase() + " ");
|
||||
}
|
||||
|
||||
// Process the elements using a forEach method
|
||||
System.out.println();
|
||||
set.forEach(e -> System.out.print(e.toLowerCase() + " "));
|
||||
System.out.println();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user