Comparator algorithms in Java provide a powerful way to define custom sorting logic for objects. COMPARE.EDU.VN offers in-depth comparisons to help you master these algorithms and apply them effectively. This article explores the comparator interface, its implementation, and its advantages in various sorting scenarios, providing clarity for developers of all levels.
1. Understanding the Java Comparator Interface
The Comparator
interface in Java is a crucial element for customizing the sorting behavior of objects. It allows you to define your own comparison logic, enabling sorting based on specific criteria that are not inherently part of the object’s natural ordering. This is particularly useful when you need to sort a collection of objects in multiple different ways or when the objects don’t have a built-in way to compare themselves.
1.1. Definition and Purpose
The Comparator
interface belongs to the java.util
package and is designed to compare two objects of the same class. Its primary purpose is to impose a specific order on a collection of objects that may not have a natural ordering or when you want to override the default ordering.
1.2. Syntax and Core Method
The Comparator
interface has one core method that you need to implement:
int compare(Object obj1, Object obj2);
This method compares two objects, obj1
and obj2
, and returns an integer value based on the comparison:
- Negative Value: If
obj1
is less thanobj2
. - Zero: If
obj1
is equal toobj2
. - Positive Value: If
obj1
is greater thanobj2
.
The implementation of this method defines the sorting logic. For example, if you’re sorting a list of students by their roll number, you would implement the compare
method to compare the roll numbers of two student objects.
1.3. Functional Interface and Lambda Expressions
Comparator
is a functional interface, meaning it has only one abstract method. This allows you to use lambda expressions for concise and readable implementations. For example:
Comparator<Student> sortByRoll = (s1, s2) -> s1.getRollNo() - s2.getRollNo();
This lambda expression creates a Comparator
that sorts Student
objects by their roll number. The lambda expression (s1, s2) -> s1.getRollNo() - s2.getRollNo()
directly implements the compare
method.
1.4. Advantages of Using Comparator
- Custom Sorting Logic: Allows you to define sorting criteria that are specific to your needs.
- Multiple Sorting Orders: You can create multiple
Comparator
implementations to sort the same collection in different ways. - External Sorting Logic: The sorting logic is external to the class being sorted, promoting separation of concerns.
- Flexibility: Works well with collections like
ArrayList
,LinkedList
, and others. - Use with Collections.sort(): Integrates seamlessly with the
Collections.sort()
method to sort lists.
2. Implementing a Comparator in Java
To implement a Comparator
in Java, you need to create a class that implements the Comparator
interface and provide an implementation for the compare
method. Here’s a step-by-step guide:
2.1. Create a Class that Implements the Comparator Interface
First, create a class that implements the Comparator
interface, specifying the type of object you want to compare using generics. For example, if you want to compare Student
objects:
import java.util.Comparator;
class SortByRoll implements Comparator<Student> {
// Implementation of compare method will go here
}
2.2. Implement the compare() Method
Next, implement the compare()
method within your class. This method should take two objects of the specified type as arguments and return an integer based on your comparison logic. Here’s an example implementation that sorts Student
objects by their roll number:
import java.util.Comparator;
class SortByRoll implements Comparator<Student> {
@Override
public int compare(Student a, Student b) {
return a.getRollNo() - b.getRollNo();
}
}
In this example, a.getRollNo() - b.getRollNo()
returns:
- A negative value if
a
‘s roll number is less thanb
‘s. - Zero if
a
‘s roll number is equal tob
‘s. - A positive value if
a
‘s roll number is greater thanb
‘s.
2.3. Using the Comparator with Collections.sort()
To use your Comparator
, pass an instance of your Comparator
class to the Collections.sort()
method when sorting a list of objects. Here’s how you can use the SortByRoll
comparator:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Main {
public static void main(String[] args) {
List<Student> students = new ArrayList<>();
students.add(new Student(111, "Mayank"));
students.add(new Student(131, "Anshul"));
students.add(new Student(121, "Solanki"));
students.add(new Student(101, "Aggarwal"));
Collections.sort(students, new SortByRoll());
System.out.println("Sorted by Roll Number:");
for (Student student : students) {
System.out.println(student);
}
}
}
This code will sort the students
list based on the roll number in ascending order.
2.4. Example: Sorting Students by Name
Let’s create another Comparator
to sort students by their name:
import java.util.Comparator;
class SortByName implements Comparator<Student> {
@Override
public int compare(Student a, Student b) {
return a.getName().compareTo(b.getName());
}
}
In this case, we use the compareTo()
method of the String
class to compare the names.
2.5. Using Lambda Expressions for Concise Comparators
You can simplify the creation of comparators using lambda expressions. For example, the SortByRoll
comparator can be written as:
import java.util.Comparator;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
List<Student> students = new ArrayList<>();
students.add(new Student(111, "Mayank"));
students.add(new Student(131, "Anshul"));
students.add(new Student(121, "Solanki"));
students.add(new Student(101, "Aggarwal"));
Comparator<Student> sortByRoll = (a, b) -> a.getRollNo() - b.getRollNo();
Collections.sort(students, sortByRoll);
System.out.println("Sorted by Roll Number:");
for (Student student : students) {
System.out.println(student);
}
}
}
This lambda expression achieves the same result as the SortByRoll
class but with less code.
3. Sorting Collections with Multiple Fields
Sorting a collection by multiple fields involves creating a Comparator
that considers more than one attribute when comparing objects. This is particularly useful when the primary sorting criterion results in ties, and you need to further refine the order.
3.1. Implementing Multi-Field Sorting
To sort by multiple fields, you implement the compare
method to first compare the primary field. If the primary fields are equal, you then compare the secondary field, and so on.
import java.util.Comparator;
class SortByNameAndAge implements Comparator<Student> {
@Override
public int compare(Student a, Student b) {
int nameComparison = a.getName().compareTo(b.getName());
if (nameComparison == 0) {
return a.getAge() - b.getAge();
} else {
return nameComparison;
}
}
}
In this example, the Student
objects are first compared by name. If the names are the same (nameComparison == 0
), the objects are then compared by age.
3.2. Alternative Method: Using thenComparing()
Java provides a more concise way to implement multi-field sorting using the thenComparing()
method of the Comparator
interface. This method allows you to chain multiple comparison criteria together.
import java.util.Comparator;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
List<Student> students = new ArrayList<>();
students.add(new Student("Ajay", 27));
students.add(new Student("Sneha", 23));
students.add(new Student("Simran", 37));
students.add(new Student("Ankit", 22));
students.add(new Student("Anshul", 29));
students.add(new Student("Sneha", 22));
// Sort students by name, then by age
students.sort(Comparator.comparing(Student::getName).thenComparing(Student::getAge));
System.out.println("After Sorting:");
for (Student student : students) {
System.out.println(student);
}
}
}
The comparing(Student::getName)
part creates a Comparator
that sorts by name, and thenComparing(Student::getAge)
adds a secondary sorting criterion based on age.
3.3. Example: Sorting Employees by Department and Salary
Consider an Employee
class with department
and salary
attributes. Here’s how you can sort a list of employees by department and then by salary:
import java.util.Comparator;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
class Employee {
private String name;
private String department;
private int salary;
public Employee(String name, String department, int salary) {
this.name = name;
this.department = department;
this.salary = salary;
}
public String getName() {
return name;
}
public String getDepartment() {
return department;
}
public int getSalary() {
return salary;
}
@Override
public String toString() {
return name + " (" + department + ", " + salary + ")";
}
}
public class Main {
public static void main(String[] args) {
List<Employee> employees = new ArrayList<>();
employees.add(new Employee("Alice", "Sales", 50000));
employees.add(new Employee("Bob", "Marketing", 60000));
employees.add(new Employee("Charlie", "Sales", 55000));
employees.add(new Employee("David", "Marketing", 55000));
employees.add(new Employee("Eve", "Sales", 50000));
// Sort employees by department, then by salary
employees.sort(Comparator.comparing(Employee::getDepartment).thenComparing(Employee::getSalary));
System.out.println("Sorted Employees:");
for (Employee employee : employees) {
System.out.println(employee);
}
}
}
This code sorts the employees first by their department and then by their salary within each department.
3.4. Advantages of thenComparing()
- Readability: Makes the code more readable and easier to understand.
- Conciseness: Reduces the amount of code needed for multi-field sorting.
- Maintainability: Simplifies the maintenance and modification of sorting criteria.
- Flexibility: Supports an arbitrary number of sorting criteria.
4. Comparator vs. Comparable
Both Comparator
and Comparable
are used for sorting objects in Java, but they serve different purposes and have distinct characteristics.
4.1. Comparable Interface
The Comparable
interface is implemented by the class whose objects you want to compare. It defines the natural ordering of the objects. The Comparable
interface has one method:
int compareTo(Object obj);
This method compares the current object to another object of the same type.
4.2. Key Differences
Feature | Comparator | Comparable |
---|---|---|
Sorting Logic Location | Defined externally | Defined within the class |
Multiple Sorting Orders | Supported | Not supported |
Interface Methods | compare() |
compareTo() |
Functional Interface | Yes | No |
Usage | Flexible and reusable | Simple and tightly coupled |
4.3. When to Use Comparable
Use Comparable
when:
- You want to define the default or natural ordering of a class.
- You want the class itself to know how its instances should be compared.
class Student implements Comparable<Student> {
private int rollNo;
private String name;
public Student(int rollNo, String name) {
this.rollNo = rollNo;
this.name = name;
}
public int getRollNo() {
return rollNo;
}
public String getName() {
return name;
}
@Override
public int compareTo(Student other) {
return this.rollNo - other.rollNo;
}
@Override
public String toString() {
return rollNo + ": " + name;
}
}
In this example, the Student
class implements Comparable
, and the compareTo
method sorts students by their roll number.
4.4. When to Use Comparator
Use Comparator
when:
- You need to sort objects based on different criteria.
- You don’t have access to modify the class you want to sort.
- You want to define multiple sorting orders for the same class.
import java.util.Comparator;
class SortByName implements Comparator<Student> {
@Override
public int compare(Student a, Student b) {
return a.getName().compareTo(b.getName());
}
}
In this case, SortByName
is a separate class that provides an alternative way to sort Student
objects by name.
4.5. Practical Comparison
Let’s say you have a Book
class and you want to sort books by title and then by author. You can use Comparable
to define the natural ordering by title and Comparator
to sort by author.
class Book implements Comparable<Book> {
private String title;
private String author;
private int publicationYear;
public Book(String title, String author, int publicationYear) {
this.title = title;
this.author = author;
this.publicationYear = publicationYear;
}
public String getTitle() {
return title;
}
public String getAuthor() {
return author;
}
public int getPublicationYear() {
return publicationYear;
}
@Override
public int compareTo(Book other) {
return this.title.compareTo(other.title);
}
@Override
public String toString() {
return title + " by " + author + " (" + publicationYear + ")";
}
}
import java.util.Comparator;
class SortByAuthor implements Comparator<Book> {
@Override
public int compare(Book a, Book b) {
return a.getAuthor().compareTo(b.getAuthor());
}
}
Here, Book
implements Comparable
to sort by title, and SortByAuthor
is a Comparator
to sort by author.
4.6. Summary Table
Feature | Comparable | Comparator |
---|---|---|
Sorting Logic Location | Within the class | External to the class |
Number of Orders | Single (natural) | Multiple |
Implementation | Implements Comparable interface |
Implements Comparator interface |
Method | compareTo() |
compare() |
Modification Required | Requires class modification | No class modification required |
Use Case | Default sorting order | Custom or alternative sorting orders |
5. Real-World Applications of Comparator Algorithms
Comparator algorithms are widely used in various real-world applications where custom sorting logic is required. Here are some examples:
5.1. E-Commerce Platforms
In e-commerce platforms, products can be sorted based on various criteria such as price, popularity, rating, and release date. Each of these sorting options can be implemented using a Comparator
.
import java.util.Comparator;
class SortByPrice implements Comparator<Product> {
@Override
public int compare(Product a, Product b) {
return a.getPrice() - b.getPrice();
}
}
class SortByRating implements Comparator<Product> {
@Override
public int compare(Product a, Product b) {
return b.getRating() - a.getRating(); // Sort in descending order
}
}
These comparators allow users to sort products according to their preferences, enhancing the shopping experience.
5.2. Sorting Search Results
Search engines use complex algorithms to rank search results. While the core ranking algorithm is intricate, comparators can be used to refine the results based on factors such as relevance, date, or user reviews.
import java.util.Comparator;
class SortByRelevance implements Comparator<SearchResult> {
@Override
public int compare(SearchResult a, SearchResult b) {
return b.getRelevanceScore() - a.getRelevanceScore();
}
}
This comparator sorts search results by their relevance score, ensuring that the most relevant results appear first.
5.3. Task Management Systems
Task management systems often allow users to sort tasks based on priority, due date, or assignee. Comparators can be used to implement these sorting options.
import java.util.Comparator;
class SortByDueDate implements Comparator<Task> {
@Override
public int compare(Task a, Task b) {
return a.getDueDate().compareTo(b.getDueDate());
}
}
This comparator sorts tasks by their due date, helping users prioritize their work.
5.4. Data Analysis and Reporting
In data analysis, comparators are used to sort data sets based on different metrics, allowing analysts to gain insights from the data.
import java.util.Comparator;
class SortBySales implements Comparator<SalesData> {
@Override
public int compare(SalesData a, SalesData b) {
return b.getSalesAmount() - a.getSalesAmount(); // Sort in descending order
}
}
This comparator sorts sales data by the sales amount, allowing analysts to identify top-performing products or regions.
5.5. Music and Media Players
Music players often allow users to sort songs by title, artist, or album. Comparators can be used to implement these sorting options.
import java.util.Comparator;
class SortByArtist implements Comparator<Song> {
@Override
public int compare(Song a, Song b) {
return a.getArtist().compareTo(b.getArtist());
}
}
This comparator sorts songs by their artist, making it easier for users to find music by their favorite artists.
5.6. Contact Management Applications
Contact management applications allow users to sort contacts by name, company, or last activity. Comparators can be used to implement these sorting options.
import java.util.Comparator;
class SortByCompanyName implements Comparator<Contact> {
@Override
public int compare(Contact a, Contact b) {
return a.getCompany().compareTo(b.getCompany());
}
}
This comparator sorts contacts by their company name, helping users organize their contacts more effectively.
6. Best Practices for Implementing Comparators
Implementing comparators effectively requires following some best practices to ensure that your code is efficient, readable, and maintainable.
6.1. Ensure Consistency with Equals
It’s important to ensure that your Comparator
is consistent with the equals()
method of the class being compared. This means that if compare(a, b)
returns 0, then a.equals(b)
should also return true, and vice versa.
6.2. Handle Null Values
Your Comparator
should handle null values gracefully. A common approach is to treat null as either the smallest or largest value.
import java.util.Comparator;
class SortByName implements Comparator<Student> {
@Override
public int compare(Student a, Student b) {
if (a == null && b == null) {
return 0;
} else if (a == null) {
return -1; // a is smaller
} else if (b == null) {
return 1; // b is smaller
} else {
return a.getName().compareTo(b.getName());
}
}
}
6.3. Use Lambda Expressions for Simple Comparisons
For simple comparisons, use lambda expressions to make your code more concise and readable.
import java.util.Comparator;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
List<Student> students = new ArrayList<>();
students.add(new Student(111, "Mayank"));
students.add(new Student(131, "Anshul"));
students.add(new Student(121, "Solanki"));
students.add(new Student(101, "Aggarwal"));
Comparator<Student> sortByRoll = (a, b) -> a.getRollNo() - b.getRollNo();
Collections.sort(students, sortByRoll);
System.out.println("Sorted by Roll Number:");
for (Student student : students) {
System.out.println(student);
}
}
}
6.4. Avoid Unnecessary Calculations
In your compare
method, avoid performing unnecessary calculations or operations that could impact performance. Focus on the core comparison logic.
6.5. Consider Performance Implications
When sorting large collections, the performance of your Comparator
can be critical. Ensure that your comparison logic is efficient and avoids complex operations.
6.6. Use thenComparing
for Multi-Field Sorting
For sorting by multiple fields, use the thenComparing
method to create a chain of comparators, making your code more readable and maintainable.
6.7. Document Your Comparators
Provide clear documentation for your comparators, explaining the sorting criteria and any special considerations.
7. Common Mistakes to Avoid
When working with comparators, there are several common mistakes that developers should avoid.
7.1. Not Handling Null Values
Failing to handle null values can lead to NullPointerException
errors. Always ensure that your Comparator
handles null values gracefully.
7.2. Inconsistent Comparison Logic
Inconsistent comparison logic can lead to unpredictable sorting results. Ensure that your Comparator
provides a consistent and well-defined ordering.
7.3. Not Ensuring Transitivity
A Comparator
must ensure transitivity, meaning that if compare(a, b) > 0
and compare(b, c) > 0
, then compare(a, c) > 0
must also be true. Violating transitivity can lead to unexpected sorting behavior.
7.4. Performing Side Effects
The compare
method should not have any side effects. It should only perform comparisons and return a result based on the input objects.
7.5. Ignoring the Return Value Convention
The compare
method must return a negative integer, zero, or a positive integer based on the comparison. Ignoring this convention can lead to incorrect sorting results.
7.6. Using ==
for Object Comparison
When comparing objects, always use the equals()
method or compare specific attributes, rather than using ==
, which compares object references.
7.7. Overcomplicating the Comparison Logic
Keep your comparison logic as simple and straightforward as possible. Avoid unnecessary complexity that could impact performance and readability.
8. Advanced Comparator Techniques
For more complex sorting scenarios, there are several advanced techniques you can use with comparators.
8.1. Reverse Order Sorting
To sort in reverse order, you can use the reversed()
method of the Comparator
interface.
import java.util.Comparator;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
List<Student> students = new ArrayList<>();
students.add(new Student(111, "Mayank"));
students.add(new Student(131, "Anshul"));
students.add(new Student(121, "Solanki"));
students.add(new Student(101, "Aggarwal"));
Comparator<Student> sortByRoll = (a, b) -> a.getRollNo() - b.getRollNo();
Collections.sort(students, sortByRoll.reversed());
System.out.println("Sorted by Roll Number (Descending):");
for (Student student : students) {
System.out.println(student);
}
}
}
This code sorts the students by roll number in descending order.
8.2. Null-Safe Sorting
To handle null values in a null-safe manner, you can use the nullsFirst()
or nullsLast()
methods of the Comparator
interface.
import java.util.Comparator;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
List<Student> students = new ArrayList<>();
students.add(new Student(111, "Mayank"));
students.add(null);
students.add(new Student(121, "Solanki"));
students.add(new Student(101, "Aggarwal"));
Comparator<Student> sortByRoll = Comparator.comparing(Student::getRollNo, Comparator.nullsFirst(Comparator.naturalOrder()));
Collections.sort(students, sortByRoll);
System.out.println("Sorted by Roll Number (Nulls First):");
for (Student student : students) {
System.out.println(student);
}
}
}
This code sorts the students by roll number, placing null values at the beginning of the list.
8.3. Dynamic Comparator Selection
You can dynamically select a Comparator
based on runtime conditions. This allows you to change the sorting criteria on the fly.
import java.util.Comparator;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
List<Student> students = new ArrayList<>();
students.add(new Student(111, "Mayank"));
students.add(new Student(131, "Anshul"));
students.add(new Student(121, "Solanki"));
students.add(new Student(101, "Aggarwal"));
String sortBy = "name"; // Can be "roll" or "name"
Comparator<Student> comparator;
if (sortBy.equals("roll")) {
comparator = (a, b) -> a.getRollNo() - b.getRollNo();
} else {
comparator = (a, b) -> a.getName().compareTo(b.getName());
}
Collections.sort(students, comparator);
System.out.println("Sorted by " + sortBy + ":");
for (Student student : students) {
System.out.println(student);
}
}
}
This code selects the Comparator
based on the value of the sortBy
variable.
8.4. Combining Comparators
You can combine multiple comparators to create a more complex sorting order. This is useful when you need to sort by multiple criteria and want to define a specific precedence.
import java.util.Comparator;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
List<Student> students = new ArrayList<>();
students.add(new Student("Alice", 25, 101));
students.add(new Student("Bob", 20, 102));
students.add(new Student("Alice", 20, 103));
students.add(new Student("Bob", 25, 104));
Comparator<Student> sortByName = (a, b) -> a.getName().compareTo(b.getName());
Comparator<Student> sortByAge = (a, b) -> a.getAge() - b.getAge();
Comparator<Student> combinedComparator = sortByName.thenComparing(sortByAge);
Collections.sort(students, combinedComparator);
System.out.println("Sorted by Name and Age:");
for (Student student : students) {
System.out.println(student);
}
}
}
This code combines the sortByName
and sortByAge
comparators to sort the students first by name and then by age.
9. Benefits of Using COMPARE.EDU.VN for Comparator Insights
COMPARE.EDU.VN offers detailed comparisons and insights into various sorting algorithms and comparator implementations. Here’s how you can benefit from using our platform:
- Comprehensive Comparisons: COMPARE.EDU.VN provides thorough comparisons of different comparator implementations, highlighting their strengths and weaknesses.
- Real-World Examples: Our platform offers real-world examples of how comparators are used in various applications, helping you understand their practical uses.
- Best Practices: COMPARE.EDU.VN provides best practices for implementing comparators effectively, ensuring that your code is efficient, readable, and maintainable.
- Advanced Techniques: Our platform covers advanced comparator techniques, such as reverse order sorting, null-safe sorting, and dynamic comparator selection, helping you tackle more complex sorting scenarios.
- Expert Insights: COMPARE.EDU.VN offers expert insights and advice on choosing the right comparator implementation for your specific needs.
- User Reviews: Our platform features user reviews and ratings, allowing you to learn from the experiences of other developers.
By using COMPARE.EDU.VN, you can gain a deeper understanding of comparator algorithms and make informed decisions about their implementation in your projects.
10. FAQ about Comparator Algorithms in Java
Q1: What is the main purpose of the Comparator
interface in Java?
The Comparator
interface is used to define custom sorting logic for objects, allowing you to sort collections based on specific criteria.
Q2: How do I implement a Comparator
in Java?
To implement a Comparator
, create a class that implements the Comparator
interface and provide an implementation for the compare
method.
Q3: What is the difference between Comparator
and Comparable
?
Comparable
is implemented by the class whose objects you want to compare, defining the natural ordering of the objects. Comparator
is implemented externally and can define multiple sorting orders for the same class.
Q4: How can I sort a collection in reverse order using a Comparator
?
You can use the reversed()
method of the Comparator
interface to sort in reverse order.
Q5: How do I handle null values in a Comparator
?
You can use the nullsFirst()
or nullsLast()
methods of the Comparator
interface to handle null values in a null-safe manner.
Q6: Can I combine multiple comparators to create a more complex sorting order?
Yes, you can combine multiple comparators using the thenComparing
method to create a chain of comparators.
Q7: What are some common mistakes to avoid when working with comparators?
Common mistakes include not handling null values, inconsistent comparison logic, and not ensuring transitivity.
Q8: How can I dynamically select a Comparator
based on runtime conditions?
You can use conditional statements to select a Comparator
based on runtime conditions.
Q9: What are some real-world applications of comparator algorithms?
Comparator algorithms are used in e-commerce platforms, search engines, task management systems, data analysis, and music players.
Q10: Where can I find more information and insights about comparator algorithms?
You can find detailed comparisons and insights on COMPARE.EDU.VN, which provides comprehensive information and real-world examples.
By understanding these FAQs, you can effectively use comparator algorithms in your Java projects and avoid common pitfalls.
Understanding and implementing comparator algorithms in Java can significantly improve your ability to sort and manage data effectively. By following the guidelines and best practices outlined in this article, you can create efficient, readable, and maintainable code. For more in-depth comparisons and expert insights, visit COMPARE.EDU.VN.
Ready to make smarter comparisons? Visit compare.edu.vn today to explore detailed comparisons and make informed decisions. Our comprehensive resources are designed to help you compare products, services, and ideas with ease. Don’t make a decision without us. Contact us at 333 Comparison Plaza, Choice City, CA 90210, United States, or reach out via Whatsapp at +1 (626) 555-9090.