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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:43:34+00:00 2026-06-13T11:43:34+00:00

I am not very skilled in Java so I consider my question as basic.

  • 0

I am not very skilled in Java so I consider my question as basic. I am writing an interface for something like ArrayResult. There will be methods add and get.

Problem is that ArrayResult can obtain values of Integer or Double. So I need to define methods in interface more generally. I figured out that it is possible to have something like this for get method:

public <N extends Number> N get(Integer index);

Is that correct? I believe this means that get method can return anything what extends Number Object. What sytax to use for add method?

public void add(Number value);

This is not what I want since add(Integer value) doesnt override the interface method.

  • 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-13T11:43:35+00:00Added an answer on June 13, 2026 at 11:43 am

    I guess what you want is

    interface ArrayResult<N extends Number> {
        public N get(Integer index);
    
        public void add(N value);
    }
    

    Then you can write two separate specific implementers

    class IntegerResult implements ArrayResult<Integer> {
        @Override
        public void add(Integer value) {
        }
    
        @Override
        public Integer get(Integer index) {
            return null;
        }
    }
    
    class DoubleResult implements ArrayResult<Double> {
        @Override
        public void add(Integer value) {
        }
    
        @Override
        public Double get(Double index) {
            return null;
        }
    }
    

    References:

    • Bounded Type Parameters
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not very skilled in php, but I believe something in this section
Sorry I realize this is a very novice question: I am not yet skilled
I'm not very good at writing regular expressions for Rails routes . I want
Maybe the title is not very descriptive. The case is the following, there's a
I'm not very skilled with regex, I was wondering if it was possible to
I'm not very skilled in web developing by the moment but i've managed to
Not very strong in PHP so here is my question: I am building a
I am not very good in regex but there is an illogic thing that
I am not very skilled in Perl, and I am trying to use FSA::Rules.
Not very good at putting this question into words.... I'm using an API to

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.