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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:01:53+00:00 2026-06-13T20:01:53+00:00

My job was to: Revise the Node class to a generic one so that

  • 0

My job was to:

Revise the Node class to a generic one so that it can handle folders and files in a file system shown below.

And also:

First, you need to modify the Node class so that both ‘size’ and ‘name’ will be replaced by one object.

Now, I did the first part where we change the class to use generic types. I’m stuck at second problem. I don’t know how to pass single object instead of 2 variables and then do bunch of computation within it.

How would I substitute multiple variables for single object here? I’ve been trying to change types and move things around but my code keeps failing as soon as I remove those 2 variables.

Code:

class Node<T>
   {
   public String name;
   public int size;
   public Node<T> leftChild;
   public Node<T> rightChild;

   public void displayNode()
      {
      System.out.print('{');
      System.out.print(name);
      System.out.print(", ");
      System.out.print(size);
      System.out.print("} ");
      }
   }  // end class Node
  • 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-13T20:01:59+00:00Added an answer on June 13, 2026 at 8:01 pm

    I would redesign it like this:

    class Node<T> {
        public T data;
        public Node<T> leftChild;
        public Node<T> rightChild;
    
        public void displayNode() {
            System.out.print('{');
            System.out.print(data.toString());
            System.out.print("} ");
       }
       . . .
    }
    

    EDIT One way to rewrite your find method is for it to find a particular T value:

    public Node<T> find(Comparable<T> target) {
        Node<T> current = root;
        int comp = target.compareTo(current.data);
        while (comp != 0) {
            if (comp < 0)
                current = current.leftChild;
            else
                current = current.rightChild;
            if(current == null)
                return null;
        }
        return current;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a job NIGHTLY that runs one time each night by a periodical
We have an email job that uses System.Net.Mail Emails get sent to a folder,
I wrote a job that generates pdf files with salesQuotation report, the files are
In a previous job we had a classic ASP application that no one wanted
My Job model has job_date field that is defined in the migration file like
I have a cron job setup that uses a script to download many files
Your job is to design a Project Plan class library which supports the tracking
A job came in to me that's built with CodeCharge - had a look
I have a job that must execute each monday. This job run in a
I am monitoring a job using Sysview on our glorious IBM mainframe. Can I

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.