Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8287653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:06:35+00:00 2026-06-08T12:06:35+00:00

I have a Java class as class Students{ private String fName; private String lName;

  • 0

I have a Java class as

class Students{
    private String fName;   
    private String lName;
    private String uName;


    public Students(String fName, String lName, String uName) {
            this.fName = fName;
            this.lName = lName;
            this.uName = uName;
     }      

    public String getuName() {
        return uName;
    }
    public void setuName(String uName) {
        this.uName = uName;
    }
    public String getfName() {
        return fName;
    }
    public void setfName(String fName) {
        this.fName = fName;
    }
    public String getlName() {
        return lName;
    }
    public void setlName(String lName) {
        this.lName = lName;
    }

}

Now I have objects created as;

    Students students1 = new Students("har","mat","harmat");
    Students students2 = new Students("pan","son","panson");
    Students students3 = new Students("yogi","jos","yogijos");

    Students students4 = new Students("har","mat","harmat");
    Students students5 = new Students("pan","son","harmat");
    Students students6 = new Students("yogi","jos","someotherUName");
    Students students7 = new Students("yogi","jos","someotherUName2");

Now all these objects get added to combinedList

List combinedList = new ArrayList<SchoolStudents>();

I want to remove duplicate objects from this combinedList based on the following criteria;
if fName is same OR if uName is same.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:06:37+00:00Added an answer on June 8, 2026 at 12:06 pm

    If that is a general criteria to determine if 2 students are equals, you could override equals and hashcode in your class to make 2 students equal based on your criteria.

    You can then add the students to a set (typically a HashSet, which will automatically remove the duplicate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java class as class Students{ private String fName; private String lName;
If I have a java class which is package-private (declared with class, not public
public class Student implements java.io.Serializable { private long studentId; private String studentName; private Set<Course>
I have a Java class, Node as follows : class Node { public ArrayList<Node>
I have a Java class class Student { String name; int age; } Also,
I have a generic java class that stores comparables: public class MyGenericStorage<T extends Comparable<T>>
This is my Student class that used to test log4j. public class Student{ private
I have a java class and I need to debug it (put breakpoints and
I have a java class containing all the columns of a database table as
I have a Java class MyPojo that I am interested in deserializing from JSON.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.