분류 전체보기
-
배열이란?JAVA/배열( array ) 2023. 5. 3. 09:54
동일한 타입의 여러개의 데이터를 담는 집합 자료형 키워드 정리 : 동일 타입, 여러개의 데이터 배열의 선언 배열을 new로 생성한뒤에는 자동초기화 가 됨. 숫자타입들은 --> 0으로 boolean타입은 --> false 로 객체타입(Object) 타입은 --> null 로. // 선언 // 자료타입[] 변수이름; int[] arr; // 선언 + 초기화 int[] korea = new int[3]; // 배열의 크기 3 korea[0] = 100; korea[1] = 90; korea[2] = 80; // 선언 + 초기화 int[] korea = new int[]{100, 90, 80}; // 선언 + 초기화 int[] korea = {100, 90, 80};// new 는 알아서 해줌 배열의 길이 배열..
-
변수JAVA/변수( variable ) 2023. 5. 2. 09:29
1. 변수란? 값을 담는 공간. 변수 이름을 부여하여 관리한다. 2. 변수의 선언 // 변수의 선언 // 변수 타입 변수이름; int num1; 동일한 타입의 변수들은 한번에 선언이 가능하다. // 정수를 나타내는 int type의 변수 선언 int num2, num3, num4; 3. 변수의 초기화 선언한 변수는 해당 타입에 맞는 값을 부여해주면 된다. // 변수 선언 int a; // 변수 초기화 a = 100; 4. 변수 생성의 규칙 변수명으로 사용가능한 것은 알파벳, 숫자, _, $ 숫자로 시작 할 수 없다 띄어쓰기 안된다 대소문자 구분해야 한다 중복 안된다 자바 기준, 일반적으로 commel notation(myHome)을 사용한다 ※ 변수명은 기본적으로 그 의미를 생각하여 부여하는 것이 좋다 ..
-
정규표현식 - 3JAVA/정규표현식 2023. 5. 1. 17:38
나중에 활용할 수 있도록 정규표현식과 설명을 간략하게 정리해두자. 정규표현식 설명 ^ 문자열의 시작 $ 문자열의 종료 . ( 점) 임의 문자 1개. 단, " ' "와 는 인식 안됨 * 바로 앞 또는 그룹() 이 0개 이상 존재 + 바로 앞 또는 그룹() 이 1개 이상 존재 ? 바로 앞 또는 그룹() 이 없거나, 1개 존재 [ ] 문자의 집합이나 범위 표현. ' - (dash)' 기호로 범위 표현 가능 ex> [0-9] 0부터 9까지 { } 바로 앞 또는 그룹() 의 등장 횟수, 또는 범위 표현 ( ) 괄호 안의 문자를 하나의 문자로 인식 >>> '그룹'이라 칭함 | 패턴을 OR 연산을 수행할 때 사용 \s vs \S \s : 공백문자 \S : 공백 문자가 아닌 나머지 문자 \w vs \W \w : 알파벳..
-
정규표현식 - 2JAVA/정규표현식 2023. 5. 1. 17:24
정규표현식에 대한 전반적인 흐름은 "정규표현식 - 1"에서 보고 넘어 왔다. 정규표현식을 만드는 다양한 규칙들이 존재하지만, 그전에 group이라는 것에 대해서 짚고 넘어가자 1. 정규표현식 : group 정규표현식에 () 을 사용하여 패턴 내에서 '그룹'을 지정하면 매칭된 정규표현식내에 그룹을 만들어 보여줄 수 있다. String input; String regex; Pattern pat; Matcher matcher; // 정규표현식 regex = "(My)(....)"; // 정규표현식에 () 사용 // Pattern 객체에 등록 pat = Pattern.compile(regex); // 입력 문자열 input = "-My98KK-myABCD--My1234567--MyZZ---My789"; // p..
-
정규표현식 - 1JAVA/정규표현식 2023. 5. 1. 11:16
1. 정규표현식이란? 문자열의 특정 규칙 / 패턴 등을 표현한 언어이다. 주로 문자열 치환, 검색 등의 동작을 할 때, 단순히 문자열들을 1 대 1 비교하는 것이 아니라, 하나의 정규표현식 문자열이 >>>> 특정 패턴(ex 주민등록번호/ url / email ...)을 비교할 수 있다. 2. 자바의 정규표현식 정규표현식을 완성하기 위해서는 3가지 준비가 필요하다 정규표현식 비교하고자하는 입력 문자열 자바에서 제공하는 2개의 클래스 자바는 java.util.regex 에서 관련 클래스를 제공한다. Pattern Matcher import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void..