Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // declares an array of integers
- int[] anArray;
- int max;
- // allocates memory for 10 integers
- anArray = new int[10];
- // initialize first element
- anArray[0] = 100;
- // initialize second element
- anArray[1] = 200;
- // and so forth
- anArray[2] = 300;
- anArray[3] = 400;
- anArray[4] = 500;
- anArray[5] = 600;
- anArray[6] = 700;
- anArray[7] = 800;
- anArray[8] = 900;
- anArray[9] = 1000;
- // postavi da je max odma prvi broj u polju
- max = anArray[0];
- for (int i = 0; i < anArray.length; i++) {
- if (anArray[i] > max) {
- max = anArray[i];
- }
- }
- System.out.println(max);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement