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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:02:27+00:00 2026-05-27T22:02:27+00:00

I read the next answer about passing function as parameter . Still, I don’t

  • 0

I read the next answer about passing function as parameter.

Still, I don’t get the idea. My function can get any function: sin(x), cos(x), etc.

As I understood, I can create an interface, for example:

public interface functionI<T> {

}

that would wrap It.

Now I have my function:

    public void needToDo(functionI<Integer> a, int x0Par, int hPar){
}

(needToDo, for example, need to substitue the x of the function n x0par and hPar, and find the Max. If I got sin(x), I need to find the max of sin(x0Par) and (sin(hPar)).

I didn’t understand how I use it in my function. How will I know what to do when I got the function, that can be anything (polynomial, sin(x), and so on)

  • 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-27T22:02:28+00:00Added an answer on May 27, 2026 at 10:02 pm

    Something like this:

    public interface Function1<RESULT,INPUT> {
        RESULT call(INPUT input);
    }
    
    public class Sin implements Function1<Double,Double> {
        public static final Sin instance = new Sin();
        private Sin() {
        }
        public Double call(Double x) {
            return Math.sin(x);
        }
    }
    
    public Double needToDo(Function1<Double,Double> aFunction, Double x0Par, Double hPar) {
       Double d1 = aFunction.call(x0Par);
       Double d2 = aFunction.call(hPar);
       return d1 > d2 ? d1 : d2;
    }
    
    public static void main(String[] args) {
        Double x0Par = 10.2;
        Double hPar = 1.9;
        Double ret = needToDo(Sin.instance, x0Par, hPar);
        System.out.println(ret);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read the next answer about load file into java application . I need
Hi all thanks to read my answer hope you can help me I am
SqlDataReader.Read() is a method which returns a bool but advanced to the next record
Read about Server push here . I want to push data to client from
Read (skimmed enough to get coding) through Erlang Programming and Programming Erlang . One
I read about unions the other day( today ) and tried the sample functions
I've read many post looking for my answer, but all are similar to this:
So having read some of the PostSharp documentation presented as an answer to my
I read a lot of question and answer on TDD and unit testing on
I'm new, but I read a lot about memory management, and really tried to

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.