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 ReverseStringRecursion { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
System.out.println("Please type a word to reverse: "); | |
String stringToReverse = scanner.nextLine(); | |
scanner.close(); |
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.io.BufferedReader; | |
import java.io.FileNotFoundException; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.util.Comparator; | |
import java.util.LinkedHashMap; | |
import java.util.Map; | |
import java.util.StringTokenizer; | |
import java.util.TreeMap; | |
import java.util.stream.Collectors; |
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 MiddleIndex { | |
public static void main(String[] args) { | |
int[] array = { 2, 4, 4, 5, 4, 1 }; | |
try { | |
System.out.println("Starting from index 0, adding numbers till index " + findMiddleIndex(array) + " and"); | |
System.out.println("adding rest of the numbers can be equal"); | |
} catch (Exception e) { | |
System.out.println(e.getMessage()); | |
} |
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 CommonValues { | |
public static void main(String[] args) { | |
int[] array1 = { 2, 7, 17, 19, 20, 45, 56, 159, 239 }; | |
int[] array2 = { 7, 12, 15, 19, 22, 34, 55, 150, 159 }; | |
findAndPrintCommonValues(array1, array2); | |
} | |
private static void findAndPrintCommonValues(int[] array1, int[] array2) { | |
System.out.println("Common values: "); |
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 BubbleSort { | |
public static void main(String[] args) { | |
int[] array = { 3, 60, 35, 2, 45, 320, 5 }; | |
printValues(array); | |
bubbleSort(array); | |
} | |
private static void printValues(int[] arrayToSort) { | |
for (int value : arrayToSort) { |
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 FibonacciSequence { | |
public static void main(String[] args) { | |
int length = readValueFromUser(); | |
int[] fibonacciSequenceArray = createFibonacciSequence(length); | |
printFullSequence(fibonacciSequenceArray); | |
} | |
private static void printFullSequence(int[] fibonacciSequenceArray) { |
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: "); |
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 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
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"); |