Array Get Values > First

hey232 232
hey232 232 used Ask the Experts™
Write a method that will return an array with all values from the given list that are greater than the first value in the given array.

Return an empty array [] if the give array is empty or if the given array contains no values greater than the first value.

The code should work regardless of the parameter passed in.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Business Systems Analyst / Software Developer
Top Expert 2015
Hi and welcome to Experts Exchange.

Note that this isn't a site where someone will just do your work for you. We are happy to help and assist you to come to a solution yourself.

So are you able to provide us with whatever you have attempted so far, any code that you already have, any errors that you may be getting or any specific questions about something that you are not sure of? This will help us to guide you in the direction that you need.
Here's something you can play around with to help get you started maybe. It doesn't use the first number in the given array, but one you enter instead.

import java.util.*;

class ArrayGet{

static int[] iA = new int[1000];
static int[] demoArray;
static int number;

public static void main(String[] args){

    for(int i=0;i<1000;i++){iA[i]=Integer.valueOf(i);}

    System.out.println("Input a number between 0 and 999");
    Scanner scanner = new Scanner(;

    number = scanner.nextInt();

    if(Arrays.binarySearch(iA,number+1)>-1){demoArray = sendBack(Arrays.copyOfRange(iA,number+1,iA.length));}
    else{demoArray = sendBack(new int[1000]);}

    for(int ii : demoArray){System.out.println(ii);}


    static int[] sendBack(int[] iArr){return iArr ; }


Open in new window

awking00Information Technology Specialist
Is the parameter passed in (i.e. the "given list") itself an array or something else?
Closed. No OP feedback.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial