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
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
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
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
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); | |
} |
NewerOlder