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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:05:12+00:00 2026-05-18T02:05:12+00:00

can somebody please explain what is wrong with my functions, thanks in advance: I

  • 0

can somebody please explain what is wrong with my functions, thanks in advance:
I have those classes:

main

 public class Main {
        public static void main(String[] args) {
            String[] inArr = {"Hi", "Great", "Man", "Yeap", "Why"};
            int[] outArr = new int[5];

            Summer summing = new Summer();
            outArr = summing.sum(inArr, 2, new sumStringToInt(), outArr); //here problem

            for(int i = 0; i < outArr.length; i++){
                System.out.println(outArr[i] + " ");
            }

        }
    }

summer

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;
    }
}

sum function

public abstract class SumFunction<Y,X> {
public abstract Y op (Y y, X x);
}

sumStrinToInt

public class sumStringToInt  extends SumFunction<Integer, String>{
    public Integer op(Integer num, String s){
        return s.length() + num;
    }
}

I have an error:

The method sum(X[], Y, SumFunction<Y,X>, Y[]) in the type Summer is not applicable for the arguments (String[], int, sumStringToInt, int[])
  • 1 1 Answer
  • 1 View
  • 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-18T02:05:12+00:00Added an answer on May 18, 2026 at 2:05 am

    Primitives and generics don’t mix.

    Make your array of the wrapper type Integer and it will compile:

    Integer[] outArr = new Integer[5];
    

    But note that you will have to initialize the array elements, because otherwise they’ll be null.

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

Sidebar

Related Questions

can somebody please explain my mistake, I have this class: class Account { private:
can somebody please explain, I have a program on C, can I convert it
can somebody please explain what this program is doing? .= torg + 1000 main:
Can somebody please explain me clearly by using some nice examples how c++ class
Can somebody please explain to me where I am going wrong? When I load
Can somebody please explain this to me: I have a label and I want
Can somebody please explain what is wrong in the below applescript: tell the application
can somebody please explain difference between those two declarations in the properties of the
Can somebody please explain how to use macros in x86 assembly coding
Can somebody please explain how to find out if full text search is enabled

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.