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
package com.alex.methods; | |
public class JavaApplication1 { | |
static double megoCalc(double first, char operation, double second) { | |
switch (operation) { | |
case '+': | |
return first + second; | |
case '-': | |
return first - second; |
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
package com.alex.methods; | |
public class Example { | |
static double withoutReturn() { | |
while (true) { | |
System.out.println("do smth..."); | |
} | |
} |
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
package com.alex.methods; | |
public class OverloadingExample { | |
static void line(int length, char symbol) { | |
for (int i = 0; i < length; i++) { | |
System.out.print(symbol); | |
} | |
System.out.println(); | |
} |
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
package com.alex.methods; | |
class VarArgs { | |
public static void sum(int[] ar) { | |
int s = 0; | |
for (int current : ar) { | |
s += current; | |
} | |
System.out.println(s); |
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
package com.alex.methods; | |
class VarArgsBadExample { | |
public static void va(int a, double b, String... s) { | |
// в методе могут быть другие параметры, кроме ... | |
} | |
public static void va(int... v) { | |
// вполне обычный метод |
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
package com.alex.recursion; | |
import java.util.Arrays; | |
import java.util.Random; | |
class BinarySearchRecursive { | |
public static void main(String[] args) { | |
int size = 20; | |
Random r = new Random(); |
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
package com.alex.recursion; | |
public class QuickSortExample { | |
static void quickSort(int ar[], int start, int end) { | |
int L = start, R = end; | |
int M = ar[(start + end) / 2]; | |
do { |
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
package com.alex.recursion; | |
import java.io.IOException; | |
public class Horse { | |
static int size = 5; | |
static int[][] ar = new int[size][size]; | |
static int shiftX[] = {1, 2, 2, 1, -1, -2, -2, -1}; |
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
package com.alex.recursion; | |
import java.io.File; | |
import java.io.IOException; | |
public class AllFiles { | |
static int totalCount = 0; | |
static void listAll(String path) |
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
package com.alex.recursion; | |
public class MineSearcher { | |
static int width = 10; | |
static int height = 10; | |
private static int checkMines(int x, int y) { | |
// подсчёт количества мин в радиусе 1 клетки от x:y | |
return 0; |