This Java code displays a list of students and their scores and also displays a list of their names in alphabetical order.
Use this command to compile this: gcj --main=Employees Employees.java -o hello
.
/* * My first Java program. * */ import java.util.Arrays; public class Employees { public static void main(String[] args) { String[] myStringArray = new String[]{"Rodney","Daniel","Bavita", "Peter", "Imran", "Lobosh", "Yuting", "Carl"}; int[] myIntArray = new int[]{333,221,401,297,116,250,354,134}; System.out.printf("\nSorted list of names.\n"); /* args is the list of Employees. */ Arrays.sort(myStringArray); for(int i = 0; i < myStringArray.length; i++) { System.out.println(myStringArray[i]); } System.out.printf("\nEnd of sorted list.\n"); for(int j=0; j< 8; j++ ) { System.out.printf("\nScore: " + myStringArray[j] + ", " + myIntArray[j] + ".\n"); } } } |