This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
public class MyArrayList { | |
private Object[] arrayList = new Object[1]; | |
private int emptyPlace = 0; | |
public void add(Object object) { | |
if (emptyPlace == arrayList.length) { | |
arrayList = Arrays.copyOf(arrayList, arrayList.length * 2); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PrimeNumbers { | |
public static void main(String[] args) { | |
System.out.println("Is 17 prime number? " + isPrimeNumber(17)); | |
System.out.println("Is 19 prime number? " + isPrimeNumber(19)); | |
System.out.println("Is 15 prime number? " + isPrimeNumber(15)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SumOfPrimeNumbers { | |
private static final int START_VALUE = 2; | |
private static final int HOW_MANY_PRIME_NUMBERS = 1000; | |
public static void main(String[] args) { | |
int currentValue = START_VALUE; | |
int primeNumbersCounter = 0; | |
int sumOfPrimeNumbers = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class MultiplicationTable { | |
public static void main(String[] args) { | |
int size = readValueFromUser(); | |
generateTable(size); | |
} | |
private static int readValueFromUser() { | |
System.out.println("Please type a size of multiplication table: "); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Factorial { | |
public static void main(String[] args) { | |
int factArg = readValueFromUser(); | |
int result = calculateFactorial(factArg); | |
System.out.println("Factorial " + factArg + " = " + result); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LeapYear { | |
private static final int LEAP_YEAR_CONDITION_VALUE = 4; | |
private static final int LEAP_YEAR_CONDITION_VALUE_2 = 100; | |
private static final int LEAP_YEAR_CONDITION_VALUE_3 = 400; | |
public static void main(String[] args) { | |
int year = readYearFromUser(); | |
if (isLeapYear(year)) { | |
System.out.println(year + " - is leap year"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class FloydsTriangle { | |
public static void main(String[] args) { | |
int howManyRows = readRowsFromUser(); | |
printFloydsTriangle(howManyRows); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Map; | |
import java.util.TreeMap; | |
public class Main { | |
public static void main(String[] args) { | |
String word1 = "Philadelhpia"; | |
String word2 = "Spring Framework"; | |
String word3 = "InputMismatchException"; | |
findAndPrintDuplicates(word1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class PerfectNumber { | |
public static void main(String[] args) { | |
int value = readValueFromUser(); | |
isPerfectValue(value); | |
} | |
private static int readValueFromUser() { | |
System.out.println("Type a value to check: "); |
OlderNewer