Vajad kellegagi rääkida?
Küsi julgelt abi LasteAbi
Logi sisse
Sulge

"testmaksimum" - 1 õppematerjal

Objektorienteeritud programmeerimise loengutekst
40
odt

Objektorienteeritud programmeerimise loengutekst

Integer[] integerArray = {1, 2, 3, 4, 5, 6}; Double[] doubleArray = {1.1, 2.2, 3.3, 4.4, 5.5}; Character[] characterArray = {'H', 'E', 'L', 'L', 'O'}; printArray(integerArray); printArray(doubleArray); printArray(characterArray); 1 2 3 4 5 6 } 1.1 2.2 3.3 4.4 } 5.5 H E L L O Tagastistüüp tüübimuutujaga public class TestMaksimum { public static > T maksimum(T x, T y, T z){ T max = x; if (y.compareTo(max) > 0) max = y; if (z.compareTo(max) > 0) max = z; return max; } public static void main(String[] args){ System.out.println("Max 3, 4, 5: " + maksimum(3, 4, 5)); System.out.println("Max 5.5, 8.8, 9.9: " + maksimum(5.5, 8.8, 9.9)); System.out.println("Max banaan pirn apelsin: " +

Informaatika → Programmeerimine
84 allalaadimist


Sellel veebilehel kasutatakse küpsiseid. Kasutamist jätkates nõustute küpsiste ja veebilehe üldtingimustega Nõustun