Integer compare(Integer a, Integer b) {
if (a != null && b != null) {
if (!a.equals(b)) {
if (a > b) {
return 1;
} else if (a < b) {
return -1;
}
}
return 0;
} else {
throw new IllegalArgumentException("Arguments must not be null");
}
}
Integer compare(Integer a, Integer b) {
if (a == null || b == null) {
throw new IllegalArgumentException("Arguments must not be null");
}
if (a.equals(b)) return 0;
if (a > b) return 1;
return -1;
}
Integer compare(Integer a, Integer b) {
if (a == null || b == null) {
throw new IllegalArgumentException("Arguments must not be null");
}
if (a.equals(b)) return 0;
return a > b ? 1 : -1;
}
if (b == 0) {
throw new IllegalArgumentException("Деление на ноль запрещено");
} else if ("/".equals(mathSign)) {
result = a / b;
} else if ("%".equals(mathSign)) {
result = a % b;
}
if (b == 0) {
throw new IllegalArgumentException("Деление на ноль запрещено");
}
if ("/".equals(mathSign)) {
result = a / b;
} else if ("%".equals(mathSign)) {
result = a % b;
}
// на книжной полке есть место?
if (booksCount < CAPACITY) {
// есть — сохраняем книгу
books[booksCount++] = book;
} else {
// места нет - выкидываем исключение с ошибкой
throw new StorageOverflowException("Ошибка: в шкафу нет свободных полок.");
}
if (booksCount >= CAPACITY) {
throw new StorageOverflowException("Ошибка: в шкафу нет свободных полок.");
}
books[booksCount++] = book;
while (true) {
// ввод 'a' и 'b'
...
if (a > b) {
System.out.println(a + " > " + b);
} else if (b > a) {
System.out.println(b + " > " + a);
} else {
System.out.println("Числа равны " + a);
break
}
}
while (true) {
// ввод 'a' и 'b'
...
if (a == b) {
System.out.println("Числа равны " + a);
break
}
if (a > b) {
System.out.println(a + " > " + b);
} else if (b > a) {
System.out.println(b + " > " + a);
}
}
if (bookCount < 10) {
...
}
int maxBooksOnShelf = 10;
if (bookCount < maxBooksOnShelf) {
...
}
for (i = 0; i < size - 1; i++) {
if (num % 2 == 0) {
static final int PLAYER_COUNT = 3;
...
for (int i = 0; i < PLAYER_COUNT; i++) {
print("Введите имя игрока: ");