MCPcopy Create free account
hub / github.com/Manvityagi/PW-Skills-Java-Course-Codes / Main

Class Main

Lecture 40/src/Main.java:1–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1public class Main {
2 static void sortFruits(String[] fruits){
3 int n = fruits.length;
4 for(int i = 0; i < n-1; i++){
5 int min_index = i;
6 for(int j = i+1; j < n; j++){
7 if(fruits[j].compareTo(fruits[min_index]) < 0){
8 min_index = j;
9 }
10 }
11 // swap fruits[min_index], fruits[i]
12 String temp = fruits[i];
13 fruits[i] = fruits[min_index];
14 fruits[min_index] = temp;
15 }
16 }
17
18 public static void main(String[] args) {
19 String[] fruits = {"kiwi", "apple", "papaya", "mango"};
20 sortFruits(fruits);
21 for(String val : fruits){
22 System.out.print(val + " ");
23 }
24 }
25}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected