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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:45:14+00:00 2026-06-09T14:45:14+00:00

In the following: public interface SomeInteface<A, B> { public B doSomething(A a); } I

  • 0

In the following:

public interface SomeInteface<A, B> {  
    public B doSomething(A a);  
} 

I want to implement a version where the method doSomething returns the parameter a back.
I tried a Holder class;

class Holder<A> {  
     public A value;  
     public(A a){this.value = a;}  
}

and return Holder. However, I am not sure how to define an implementation class of SomeInterface so that I am able to do this.

The following does not even compile:

public class SomeImplementation<X> implements SomeInterface<T> {  

  private class Holder<A> {  
    public A value;  

    public class Holder<A>{  
      public A value;  
      public(A a){this.value = a;}  
    } 
  }   

  class Implementation<A, Holder<A>> implements SomeInterface<A, Holder<A>>{    
    public Holder<A> doSomething(A a){  
      //do stuff      
      return new Holder(a);  
    }   
  }      
}       

What am I messing up here?

  • 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-09T14:45:15+00:00Added an answer on June 9, 2026 at 2:45 pm

    It needs to be

    class Implementation<A> implements SomeInteface<A, Holder<A>>{    
              public Holder<A> doSomething(A a){  
                  //do stuff  
                  return new Holder<A>(a);  
              }     
    
       } 
    

    In the classname you define the generic variables and their constraints. You don’t need a Holder variable.

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

Sidebar

Related Questions

I use the following: public interface IRepository<T> { void Add(T entity); } public class
I have something like following: public interface A { .... } public abstract class
I used an interface and class similar to following: public interface IIdentity { int
Is it possible to somehow implement the following scheme: public interface ISomething { void
I have the following: public interface ISubject { ... } public class Subject<T> :
I have the following classes public interface InterfaceBase { } public class ImplementA:InterfaceBase {
I have the following case: public interface IPerson { .. } public class Person
How would you name a class with the following public interface: /// <summary> ///
Code I have the following class with a member interface: package com.example.withinterface; public class
In Java, you can do the following : public interface IEngine{} public interface ICoolEngine

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.