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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:18:45+00:00 2026-06-07T21:18:45+00:00

My code is:- class abc<T> { T a, b; abc(T p, T q) {

  • 0

My code is:-

class abc<T> {
    T a, b;
    abc(T p, T q) {
        a = p;
        b = q;
    }
    void disp() {
        System.out.println("\na = " + a);
        System.out.println("b = " + b);
        System.out.println("a/b is of class type : " + a.getClass().getName());
    }
}

class temp {
    public static void main(String...args) {
        abc<Integer> a1;
        a1 = new abc <Integer>(11, 22);
        abc<Byte> a2 = new abc <Byte>(50,5);
        a1.disp();
        a2.disp();
    }
}

OUTPUT:-

temp.java:23: cannot find symbol
symbol  : constructor abc(int,int)
location: class abc<java.lang.Byte>
            abc <Byte> a2 = new abc <Byte> (50,5);
                            ^
1 error

Please help me out in this question. I am new to java, so learning about generics.

In this code wen I used Integer, Float, Double, String all were working fine but when I get to Byte class the compiler throws an error.

  • 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-07T21:18:46+00:00Added an answer on June 7, 2026 at 9:18 pm

    How about this?

    abc <Byte> a2 = new abc <Byte> ((byte)50, (byte)5);
    

    The parameters you provide as numeric literals are of type integer, and those are automatically boxed to java.lang.Integer and that’s why a corresponding method is not initially found unless you explicitly say that your literals are of type byte.

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

Sidebar

Related Questions

public class ABC{ public static void main(string... as) { char i; i = System.console().readLine(Hi
In the following code public class Test { public static void main(String[] args){ int
I have following code snippet: class ABC{ public: int a; void print(){cout<<hello<<endl;} }; int
import java.io.*; public class Demo{ public static void main(String[] args){ File f = new
I have my code organized as following class MyClass { public: typedef void (MyClass::Ptr2func)();
Please find the code sample below: public class Abc extends Activity implements OnClickListener{ private
using System; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { public void
Possible Duplicate: Who calls the main function in java? Consider this code: class abc
My code class Union { //Search Function static boolean search(int A[], int i) {
I have the code: class Point3D{ protected: float x; float y; float z; public:

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.