...
Документация по GC - https://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html
Примеры
Блок кода | ||||||
---|---|---|---|---|---|---|
| ||||||
static char[] alphabet;
static {
alphabet = new char[26];
for (char c = 'a'; c <= 'z'; c++) {
alphabet[c - 'a'] = c;
}
}
public static void main(String ... args) {
while(true) {
String word = "";
for (int i = 0; i < 1000; i++) {
word += alphabet[(int)(Math.random()*26)];
}
System.out.println("word = " + word);
}
}
private static recurrent(int i) {
recurrent(++i);
} |
Строки
Интернирование
Блок кода | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
String s1 = "Hello, World"; String s2 = "testHello, World"; System.out.println("Comparing s1 and s2"); System.out.println(s1 == s2); System.out.println(s1.equals(s2)); System.out.println("Comparing s1 and s3"); String s3 = new String(s1); System.out.println(s1 == s3); System.out.println(s1.equals(s3)); System.out.println("Interning s1 and s3"); System.out.println(s1 == s3.intern()); System.out.println("Comparing concatenated strings"); String s4 = s1+"!"; System.out.println(s4 == s1+"!"); System.out.println(s4 == (s1+"!").intern()); System.out.println(s4.intern() == (s1+"!").intern()); System.out.println(s4.equals(s1+"!")); |
...
Постановка: CurrencyExchange.zip
Чтобы открыть проект в Idea:
- Cкачать и распаковать
- В Idea ds,выбрать File→Open и выбрать распакованную директорию с проектом
Quantity
Необходимо реализовать класс Quantity с поддержкой единиц измерения и арифметических операций: add, subtract, multiply, divide
Проект: Quantity.zip
Материалы
Презентация: Типы данных в Java
...