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

  • Home
  • SEARCH
  • 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 3339176
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:27:43+00:00 2026-05-18T00:27:43+00:00

about answers below, thanks a lot but it doesn’t work, may be problem also

  • 0

about answers below, thanks a lot but it doesn’t work, may be problem also with loop for in main?

hello everyone I have some problems in Java, I have those declarations:

Double first1 = 1.2;
Integer first2 = 1;

Object[] input = {first1, first2};

after I’m trying to call some function from this class:

public class Summer{
    public <Y> void sum(Y first){
        //do something
    }
}

but I receive an error:

The method sum(Y) in the type Summer is not applicable for the arguments (Object)

can somebody explain please why and how can I make it right, thanks in advance

Edited, I have a lot of code:

public class Main {
    public static void main(String[] args) {

        //arrays for input
        Integer[] intInput1 = {0, 1, 2, 3, 4};
        Integer[] intInput2 = {-3, -2, -1, 0 , 1};
        Boolean[] boolInput = {false, false, false, false, false};
        String[] stringInput = {"abc", "abc", "abc", "abc", "abc"};
        Character[] charInput = {'a', 'a', 'a', 'a', 'a'};

        //arrays for output
        Double[] output1 = new Double[5];
        Boolean[] output2 = new Boolean[5];
        Integer[] output3 = new Integer[5];
        Integer[] output4 = new Integer[5];
        String[] output5 = new String[5];

        //declaring first element
        Double first1 = 1.2;
        Boolean first2 = false;
        Integer first3 = 1;
        Integer first4 = 2;
        String first5 = "mama";

        //for saving from repetition
        Object[] first = {first1, first2, first3, first4, first5};
        Object[] output = {output1, output2, output3, output4, output5};
        Object[] input = {intInput1, intInput2, boolInput, stringInput, charInput};
        Object[] foo = {new sumIntToReal(), new sumIntToBool(), new sumBoolToInt(),
                new sumStringToInt(), new sumCharToString()};

        Summer summing = new Summer();

        for(int j = 0; j < 5; j++){
            summing.sum(input[j], first[j], foo[j], output[j]);

        }


    }//function main ends
}//class ends

sum

public class Summer{
    public <X,Y> Y[] sum(X[] inArr, Y first, SumFunction<Y,X> f, Y[] outArr){
        for(int i = 0; i < inArr.length; i++){
            outArr[i] = f.op(first, inArr[i]);
            first = outArr[i];
        }
        return outArr;
    }
}

error

The method sum(X[], Y, SumFunction<Y,X>, Y[]) in the type Summer is not applicable for the arguments (Object, Object, Object, Object)
  • 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-05-18T00:27:43+00:00Added an answer on May 18, 2026 at 12:27 am

    Your declarations for first, output, input and foo are declared as Object[]. Therefore when you make the function call summing.sum(input[j], first[j], foo[j], output[j]); it thinks you are passing four Objects. However you’re passing an Object[] for your input and output. Therefore your declarations should be

    Object[][] input = {intInput1, intInput2, boolInput, stringInput, charInput};
    Object[][] output = {output1, output2, output3, output4, output5};
    

    That way, when you make the function call, it’s passing an Object[] instead of just an Object.

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

Sidebar

Related Questions

I know there are a lot of answers about that problem, but I need
I posted earlier (and received valid answers, thanks) about a problem I had loading
I see many question/answers about how to convert a Hashtable to a Dictionary, but
There are nice SO question and answers about this issue, but these options didn't
I've read a lot of articles and answers about paging in MVC. I've managed
I know similar questions have been asked, but I'm not sure about the answers
I've read many answers here about this topic, but everyone suggests the BCP ||
THANKS: Both answers here are very helpful, but I could only pick one. I
I found already about 5 answers, tried all of them and didn't get it
I have been exploring different answers about release management in Mercurial and almost found

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.