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 7564209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:51:19+00:00 2026-05-30T13:51:19+00:00

Im a newbie coder and I was getting very frustrated because I keep getting

  • 0

Im a newbie coder and I was getting very frustrated because I keep getting compiler errors. This is a homework assignment and what I’m suppose to do is implement the Comparable class to compare any two String objects so it will return the maximum and minimum. I keep getting compiler errors and I dont exactly know why I do.

public class DataSet implements Comparable
{
   private Object maximum;
   private Object least;
   private int answer;

public int compareTo(Object other)
{
answer = this.getName().compareTo(other.getName());
return answer;

}

public Object getLeast(Object other)
 {
   if(answer<0)
   return this;
   else
   return other;
  }

 public Object getMaximum(Object other)
 {
   if(answer>0)
   return this;
   else
   return other;
 }


}

the error is the getName Method

public interface Comparable
{
    public int compareTo(Object anObject);
}


public class DataSetTester
{
public static void main(String[] args)
{
    DataSet ds = new DataSet();
    String s = "john";
    String a = "bob";
    ds.s.compareTo(a);
    System.out.println("Maximum Word: " + ds.getMaximum());
    System.out.println("Least Word: " + ds.getLeast());

 }
}


incompatible types
    String s = "john";

incompatible types
    String a = "bob";

error: cannot find symbol
    ds.s.compareTo(a);

 error: method getMaximum in class DataSet cannot be applied to given types;
    System.out.println("Maximum Word: " + ds.getMaximum());
error: method getLeast in class DataSet cannot be applied to given types;
    System.out.println("Least Word: " + ds.getLeast());
  • 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-05-30T13:51:20+00:00Added an answer on May 30, 2026 at 1:51 pm

    String already implements Comparable interface, so I’m not sure what exactly your task is.

    answer = this.getName().compareTo(other.getName());
    

    Object has no getName() method. If you implemented it in DataSet you need to change the type of other or add a cast:

    answer = this.getName().compareTo(((DataSet)other).getName());
    

    .

    incompatible types
        String s = "john";
    

    This is strange. Maybe you created your own String class? If so, you cannot assign java’s String to your String

    error: cannot find symbol
        ds.s.compareTo(a);
    

    DataSet has no field s. Expression ds.s is not valid.

    error: method getMaximum in class DataSet cannot be applied to given types;
        System.out.println("Maximum Word: " + ds.getMaximum());
    

    You need to add argument to getMaximum() e.g. getMaximum(null). Or, remove the argument from method declaration.

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

Sidebar

Related Questions

Python newbie getting a bit frustrated with the csv module. At this rate, it
I'm a newbie at VBA and html and I'm getting very confused. I'm trying
Ol' newbie here again ... I'm getting this message cannot find symbol for all
Hello all I'm a java newbie and I'm getting a compiler error message: src\LU62XnsCvr.java:33:
I am an ASP.NET MVC newbie. I am getting a very strange error when
This feels like a newbie question, so brace yourself. I am having difficulty getting
I'm a newbie in boost.python and i'm getting this error that I would like
I'm a newbie to python and the app engine. I have this code that
I'm a jQuery newbie as of this morning, and this is the code I've
I'm newbie in Python. I can't understand why this code does not work: reOptions

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.