34 lines
581 B
Java
34 lines
581 B
Java
package Practice.test3;
|
|
|
|
public class findmax {
|
|
// Get max value from array
|
|
public static int findMax(int[] arr){
|
|
int max = 0;
|
|
for (int i = 1; i < arr.length; i++){
|
|
if (arr[i] > arr[max]){
|
|
max = i;
|
|
}
|
|
}
|
|
return max;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
class Counter{
|
|
public Counter(int count) {
|
|
this.count = count;
|
|
}
|
|
private int count = 0;
|
|
public void increment(){
|
|
count++;
|
|
}
|
|
public int getCount(){
|
|
return count;
|
|
}
|
|
public int decrement(){
|
|
return count--;
|
|
}
|
|
|
|
}
|