Array Get Values > First

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.
hey232 232Asked:
Who is Participating?
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
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.
0
 
krakatoaCommented:
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(System.in);

    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

0
 
awking00Commented:
Is the parameter passed in (i.e. the "given list") itself an array or something else?
0
 
krakatoaCommented:
Closed. No OP feedback.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.