Содержание
- 2. Массивы в Java – hard coded public static void main(String[] args) { System.out.println("Hi!"); int [] a1
- 3. Массивы в Java – динамическое создание private static final int ARRAY_SIZE = 5; … int []
- 4. Вывод массива – for 2 видов for (int i = 0; i System.out.printf("%d ", a2[i]); }
- 5. For как foreach for(int ai : a1) { ai *= 10; } for(int ai : a1)
- 6. Двумерный массив – hard coded public static void main(String[] args) { System.out.println("Hi!"); int [][] aa1 =
- 7. Двумерный массив – динамическое создание private static final int N = 5; private static final int
- 8. Двумерный массив – вывод в виде матрицы for (int i = 0; i for (int j
- 9. Двумерный массив – ввод из текстового файла «Чтение матриц из текстового файл - Java SE» http://www.cyberforum.ru/java-j2se/thread269776.html
- 10. Двумерный массив – ввод из текстового файла (2) import java.io.FileInputStream; import java.io.IOException; public class TestArray2File {
- 11. Двумерный массив – ввод из текстового файла (3) public static void main(String args[]) throws IOException {
- 12. Двумерный массив – ввод из текстового файла (4) int n = next(numbers); int m = next(numbers);
- 13. Двумерный массив – ввод из текстового файла (5) Содержимое файла "C:\\Temp\\java\\lect2\\in1.txt"
- 14. Экзаменационная задача B0 Общее задание Ввести двумерный массив из файла. Количество элементов не более 10x10. Каждый
- 15. Экзаменационная задача B0 (2) import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; public class
- 16. Экзаменационная задача B0 (3) private static int currentIndex = -1; private static int next(String [] numbers)
- 17. Экзаменационная задача B0 (4) String text = new String(str); String[] numbers = text.split("\\D"); n = next(numbers);
- 18. Экзаменационная задача B0 (5) /* * Переставить столбцы, содержащие минимальный и максимальный элементы */ private static
- 19. Экзаменационная задача B0 (6) for (int i = 0; i int tmp = array[i][minJ]; array[i][minJ] =
- 20. Экзаменационная задача B0 (7) private static void printArray() { for (int i = 0; i for
- 21. Экзаменационная задача B0 (8) «Как записывать в файл?» http://devcolibri.com/1141 (2017) https://devcolibri.com/java-%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%B0-%D1%81-%D1%84%D0%B0%D0%B9%D0%BB%D0%B0%D0%BC%D0%B8/ (2018) private static void saveArray(String
- 22. Экзаменационная задача B0 (9) try { out.println(n + " " + m); for (int i =
- 23. Экзаменационная задача B0 (10) Входной и выходной файл
- 24. Демо – визуализация массива в Java Исследуем приложение, которое визуализирует обработку массива. Предусмотрим следующие возможности («фичи»
- 25. Класс панели для визуализации массива import java.awt.Graphics; import javax.swing.JPanel; public class ArrayPanel extends JPanel { ArrayField
- 26. Класс главного окна приложения
- 27. Класс главного окна приложения (2) public class Lect2Win { private JFrame frame; private ArrayField arrayField; private
- 28. Класс главного окна приложения (3) … private void initialize() { frame = new JFrame(); frame.setBounds(100, 100,
- 29. Класс главного окна приложения (4) JButton btnInit = new JButton("init1()"); btnInit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent
- 30. Класс главного окна приложения (5) btnInit_1 = new JButton("init2()"); btnInit_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e)
- 31. Класс главного окна приложения (6) btnInit_2 = new JButton("init3()"); btnInit_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e)
- 32. Класс главного окна приложения (7) btnInit_3 = new JButton("init4()"); btnInit_3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e)
- 33. Класс главного окна приложения (8) buttonUp = new JButton("^"); buttonUp.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e)
- 34. Класс главного окна приложения (9) buttonDown = new JButton("v"); buttonDown.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e)
- 35. Класс главного окна приложения (10) buttonLeft = new JButton(" buttonLeft.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e)
- 36. Класс главного окна приложения (11) buttonRight = new JButton(">"); buttonRight.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e)
- 37. Класс главного окна приложения (12) textArea = new JTextArea(); textArea.setFont(new Font("Monospaced", Font.BOLD, 18)); textArea.setBounds(10, 271, 191,
- 38. Класс массива import java.awt.Color; import java.awt.Graphics; public class ArrayField { private int [][]array; private int n;
- 39. Класс массива (2) public void init1() { array = new int[][] { {0, 0, 0, 0,
- 40. Класс массива (3) public void init2() { array = new int[][] { {0, 0, 0, 0,
- 41. Класс массива (4) public void init4() { array = new int[][] { {1, 2, 3, 4,
- 42. Класс массива (5) public void toLeft() { for (int i = 0; i for (int j
- 43. Класс массива (6) public void down() { for (int i = n - 1; i >
- 44. Класс массива (7) public void replaceMinMaxColumns () { int maxJ = 0; int minJ = 0;
- 45. Класс массива (8) public String toString() { String str = ""; for (int i = 0;
- 46. Класс массива (9) final public static int CELL_HEIGHT = 24; final public static int CELL_WIDTH =
- 47. Цветовая палитра Color []colors = { new Color(0, 0x33, 0), new Color(0, 0x99, 0x33), new Color(0x33,
- 48. Домашнее задание Делайте лабы Делайте курсовую работу
- 50. Скачать презентацию