我有ArrayList一些记录和一个列包含气体名称为CO2 CH4 SO2等.现在我想要检索不同的气体名称(唯一),只是没有重复ArrayList.怎么做到呢?
假设我有一个名为 MyClass 的类,如下所示:
public class MyClass
{
//Identifier is alpha-numeric. If the identifier starts will 'ZZ'
//is special special identifier.
private String identifier = null;
//Date string format YYYY-MM-DD
private String dateString = null;
//Just a flag (not important for this scenario)
private boolean isCoolCat = false;
//Default Constructor and getters/setters implemented
//Overrides the standard Java equals() method.
//This way, when ArrayList calls contains() for MyClass objects
//it will only check the Date (for ZZ identifier)
//and identifier values against …Run Code Online (Sandbox Code Playgroud)