This file contains 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.Random; | |
public class RandArray { | |
public static void main(String[] args) { | |
int[] array = new int[200_000_000]; | |
Random rn = new Random(); | |
for (int i = 0; i < array.length; i++) { | |
array[i] = rn.nextInt(10); | |
} | |
} |
This file contains 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.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
public class CopyFile { | |
public static void main(String[] args) { | |
try (FileInputStream fis = new FileInputStream("a.txt"); | |
FileOutputStream fos = new FileOutputStream("acopy.txt")) { //блок try c ресурсами | |
byte[] bufer = new byte[1024]; //буфферный массив |
This file contains 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.File; | |
import java.io.FileFilter; | |
/** | |
Класс, который реализует интерфейс FileFilter и используется для поиска файлов только с тем расширением, | |
которое передано его конструктору в качестве параметра | |
MyFilter filter = new MyFilter("doc"); |
This file contains 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 Main { | |
public static void main(String[] args) { | |
int[] mas = {2, 11, 4, 144, 32, 58, 1}; | |
boolean isSorted = false; | |
while (!isSorted){ | |
isSorted = true; | |
for (int i = 0; i <mas.length-1 ; i++) { | |
if (mas[i] > mas[i+1]){ |
NewerOlder