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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:54:51+00:00 2026-06-14T11:54:51+00:00

I am trying to write a method with the following header: public static boolean

  • 0

I am trying to write a method with the following header:

public static boolean difference(int[] numbers, int size, int difference) {...}

I want it to be able to determine if it is possible to choose any two integers from the list “numbers” such that the difference between them is equal to the parameter “difference”.

So far I was thinking that I should create a list where the elements contain all possible combinations of the elements in list “numbers” and then fill another list of all possible difference values.

Then I would finally check if the parameter “difference” is inside that list. If it is then it would return true. I also want to do this recursivly so any help would be appreciated. thanks!

  • 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-14T11:54:52+00:00Added an answer on June 14, 2026 at 11:54 am

    I’m assuming you’re trying to learn about recursion, and I’m assuming this is homework. I won’t give you a code example, but I hope this helps you.

    Maybe you need to think about how to break your problem up into simpler sub problems. Perhaps instead of the harder problem of finding a pair in the list with a given difference, you could write a method that just checked whether the right difference could be found by taking the number at the start of the list and comparing it to all the other numbers in the list.

    Then, maybe you could modify your method so that it pops off the number at the start, checks against the rest of the list, and if unsuccessful calls itself with the rest of the list? Think about what to return. If you get this far you’ve done it. Watch out for what happens when you run out of elements left in the list.

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

Sidebar

Related Questions

I'm trying to write a method like this: public static T Test<T>() { if
I'm trying to write a method that does the following: public class GridCounting {
I'm trying to write a method to reduce the size of any image 50%
I have the following method for which I am trying to write a unit
I am trying to write a unit test for the following method in my
I'm trying to write a method that does the following: Replace every occurrence of
I am trying to write the result of the following method to a webpage.
I'm trying to write a method that will compute all permutations of a power
I am trying to write a method in Java that accepts a string as
I am trying to write a method that adapts to different types of interfaces

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.