The JavaTM Tutorial

| Start of Tutorial > Start of Trail > Start of Lesson | Search Feedback Form

Trail: Learning the Java Language
Lesson: Language Basics

## Answers to Questions and Exercises: Operators

### Answers to Questions

> 1. Question: Identify all of the operators in the `SortDemo` program.
>    Answer: Here's the sort program again with the variables declarations shown in red:

>    >     public class SortDemo {
>    >         public static void main(String[] args) {
>    >             int[] arrayOfInts = { 32, 87, 3, 589, 12, 1076,
>    >                                   2000, 8, 622, 127 };

>    >             for (int i = arrayOfInts.length; --i >= 0; ) {
>    >                 for (int j = 0; j < i; j++) {
>    >                     if (arrayOfInts[j] > arrayOfInts[j+1]) {
>    >                         int temp = arrayOfInts[j];
>    >                         arrayOfInts[j] = arrayOfInts[j+1];
>    >                         arrayOfInts[j+1] = temp;
>    >                     }
>    >                 }
>    >             }

>    >             for (int i = 0; i < arrayOfInts.length; i++) {
>    >                 System.out.print(arrayOfInts[i] + " ");
>    >             }
>    >             System.out.println();
>    >         }
>    >     }

| Start of Tutorial > Start of Trail > Start of Lesson | Search Feedback Form