Skip to content

Instantly share code, notes, and snippets.

@MLabusquiere
Created April 25, 2014 12:16
Show Gist options
  • Save MLabusquiere/11287626 to your computer and use it in GitHub Desktop.
Save MLabusquiere/11287626 to your computer and use it in GitHub Desktop.
package fr.zenika.vertx.app.starter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
/**
* @author M. Labusquière
*/
public class TestCollectionMain {
public static void main(String[] args) {
Collection<String> col1 = getNewCol();
Collection<String> col2 = getNewCol();
System.out.println(col1.equals(col2)); //true
System.out.println(Collections.unmodifiableCollection(col1).equals(col2));//false
System.out.println(col1.equals(Collections.unmodifiableCollection(col2)));//false
System.out.println(Collections.unmodifiableCollection(col1).equals(Collections.unmodifiableCollection(col2)));//false
}
public static Collection<String> getNewCol() {
Collection<String> col = new ArrayList<>();
return col;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment