Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What will be returned by getSmallest(…) method when you run this program? #79

Open
Shiro0521 opened this issue Sep 20, 2021 · 0 comments

Comments

@Shiro0521
Copy link

`import java.util.Scanner;
public class ArrayMethods
{
static Scanner kb = new Scanner (System.in);
public static void main(){
int[] arr = {12, 44, 13, 26, 24, 22, 33, 11, 25, 5, 37, 41};

    int min = getSmallest(arr, 0, 6);
}
public static int getSmallest(int [] arr, int a, int b){
    int minNum=arr[a];
    for(int index = a + 1; a < b; a++)
        if(arr[index] < minNum)
            minNum = arr[index];

    return minNum;
}

}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant