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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:46:58+00:00 2026-06-12T23:46:58+00:00

for a long while, i have been trying to get a piece of code

  • 0

for a long while, i have been trying to get a piece of code to work, and it just is not possible. the class i have requires a generic which i have set to Integer. so i tried the follwoing:

public class a<T> //set generics for this function
{
    private T A;
    protected boolean d;

    public a(final T A)
    {
        this.A = A;

        //do calculations
        //since constructor cannot return a value, pass to another function.
        this.d = retnData(Integer.parseInt(A.toString()) != 100); //convert to an integer, the backwards way.
    }
    private boolean retnData(boolean test)
    {
        return test;
    }
}
// IN ANOTHER CLASS
transient a<Integer> b;
boolean c = b.d = b.a(25); // throws an erorr: (Int) is not apporpriate for a<Integer>.a

Java will not allow this since java sees that int != Integer, even though both accept the same data. and because of the way generics works i cannot set a b; because of the primitiveness of the type int. Even casting to an Integer does not work, as it still throws the “type error”

finnaly, i have to ask if there is some sort of work around for this, or is it futile to try and get this to work?

  • 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-12T23:46:59+00:00Added an answer on June 12, 2026 at 11:46 pm

    You are trying to explicitly call a constructor as an instance method. This cannot be done in Java.

    Perhaps you want:

    transient a<Integer> b = new a<Integer>(25);
    boolean c = b.d;
    

    However, since d is declared to be protected, that will only work if this code is in another class derived from a or in the same package.

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

Sidebar

Related Questions

I’ve been trying to get this to work for a while but can’t (I
well I have been trying to get Nivo Slider to work almost all day.
I've been trying to get this code to work for what feels like an
I have been trying for a long time to get SQL Server Express on
I have been messing with this for too long trying to get it to
I have a small file test.txt contains a Long number inside while another piece
I have the following code in specman: var x := some.very.long.path.to.a.variable.in.another.struct; while (x ==
I have been trying for some time to create a class/series of classes that,
I am trying to get a guest book to work using PHP. I have
I have been trying to work with NIO SocketChannels for some time now, and

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.