array5 Day42_배열, 배열의 다양한 기능 2023.10.17 Day42 네 줄 요약 push와 unshift를 통해 배열에 값을 추가로 삽입할 수 있다. pop과 shift를 통해 배열에 값을 제거할 수 있다. join = array to string, split = string to array delete는 값만 삭제되고 index는 유지, splice는 해당 index 자체가 삭제됨 배열 값 추가 삭제 push 배열의 마지막 index에 값 추가 pop 배열의 맨 마지막 index 값을 삭제 shift 배열의 첫 번째 index 값을 삭제 unshift 배열의 첫 번째 index에 값 추가 source code [push] result [pop] result [shift] result [unshift] result join / split j.. 2023. 10. 21. Day08_ArrayList<>, DateTimeFormatter 2023.08.23 Day08 요약 - 배열을 사용할 때 ArrayList를 사용하면 길이 상관 없이 사용가능 - 현재 날짜, 시간을 받을 때는 DateTimeFormatter 사용 List - ArrayList List 변수명 = new ArrayList(); 배열에서는 길이를 정의해야 하지만, ArrayList에서는 자동으로 index 배정 (0, 1, 2, ...) // 아래 두 문장은 같은 의미, 다만 배열의 경우 length값이 필요 Student[] list = new Student[10]; ArrayList list = new ArrayList(); (변수이름).size() 해당 Array의 길이, 저장되는 만큼 늘어남 (변수이름).add(객체이름) 해당 객체를 변수에 저장 (변수이름).ge.. 2023. 8. 24. Day06_배열예제2 예제 source code package day06; import java.util.Scanner; public class Example_7 { public static void main(String[] args) { // TODO Auto-generated method stub // 사이트 회원가입 Scanner sc = new Scanner(System.in); String[] name = new String[10]; String[] id = new String[10]; String[] pw = new String[10]; int cnt = 0; int loginIndex = -1; while (true) { boolean run = true; System.out.println("==========라.. 2023. 8. 21. Day05_배열예제 예제 source code package day05; import java.util.Scanner; public class Example_5 { public static void main(String[] args) { // TODO Auto-generated method stub // 성적표 Scanner sc = new Scanner(System.in); String[] name = new String[10];// index0~9까지 길이 10짜리 배열 int[] kor = new int[10]; int[] mat = new int[10]; int[] eng = new int[10]; double[] avg = new double[10]; String[] grade = new String[10]; in.. 2023. 8. 20. Day04_while(boolean), 배열(Array) 2023.08.17 (Day04) Day04 세 줄 요약 - boolean type 변수를 활용해서 조건문으로 while문 exit 가능 - for 문에는 ' ; (semicolon)' 두 개만 있으면 됨 - 배열의 길이는 index + 1 while while(boolean) 조건식에 boolean type인 'true' / 'false' 중 하나를 사용해서 반복문 수행가능 - boolean run = true; - while (run) { - 함수내용... - if (a == 0) { // 'a = 0'이 break 조건 - run = false; // while(true) -> while(false)로 바뀜 - } // if문 종료 후 while(false)이므로 exit 배열 (Array) 배열[.. 2023. 8. 17. 이전 1 다음