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

  • Home
  • SEARCH
  • 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 6776593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:02:52+00:00 2026-05-26T16:02:52+00:00

Here is my code, pretty simple really. Its not homework, I’m teaching myself java

  • 0

Here is my code, pretty simple really. Its not homework, I’m teaching myself java through an education book:


import java.util.*;

/** @author Chris */

public class Exercise9_9 extends GregorianCalendar
{   
    public static void main(String[] args)
    {
        String[] stringList = {"s", "c", "b", "f", "e", "q", "g", "w", "i", "o"};
        Integer[] integerList = {5, 7, 8, 9, 6, 5, 4, 1, 2, 3};
        Calendar[] calendarList = new Calendar[10];

        for (int a = 0; a < calendarList.length; a++)
        {
            calendarList[a] = new GregorianCalendar();
            calendarList[a].set(Calendar.YEAR, ((int)Math.random()* 1000));
        }

        System.out.println("Largest String: " + max(stringList));
        System.out.println("Largest int: " + max(integerList));
        **System.out.println("Largeset date: " + (max(calendarList)).toString());**
    }

    public static Object max(Object[] a)
    {
        Arrays.sort(a);
        return a[a.length-1];
    }

    **@Override
    public String toString()**
    {
        return "Test";
    }  
}

The question is to produce three arrays: int, String and Calendar type. Then pick out the biggest out of each category (and display the answers).

This class extends the GregorianCalendar class which means I have access to the Calendars toString() which I’m trying to override. However it doesn’t work. Its like the toString() method isn’t overriding because I’m getting the default toString() output. However, I’m using Netbeans and it acknowledges the override and even takes me to to Calendar.toString() when I click the override link. So I’m stuck, any help would be appreciated.

  • 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-26T16:02:53+00:00Added an answer on May 26, 2026 at 4:02 pm

    It’s because you are not using your class, but GregorianCalendar:
    calendarList[a] = new GregorianCalendar();

    change this to
    calendarList[a] = new Exercise9_9 ();

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

Sidebar

Related Questions

It's pretty difficult to show code for ASP.NET here, so I will try my
Well, I'm gonna be pretty straightforward here, I just have a piece of code
enter code here Hi All, I have a simple windows service application that connects
There is a really similar question here , but the provided answer does not
Pretty simple task, but the source code doesn't do required job... Please advise. There
Ok the error is showing up somewhere in this here code if($error==false) { $query
Here is code from MSDN . I don't understand why the work isn't just
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),
enter code here I have a table on SQL server 2005 with bigint primary
The code here is X++. I know very little about it, though I am

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.