반응형 전체 글207 [자바기초.026] 문자열 비교하기(Comparing String) [자바기초.026] 문자열 비교하기(Comparing String) 1. 문자열이 같은지 비교 (String Equality) equals() 메소드는 두 개의 객체(object)가 같은지 비교하는 명령어 이다. 문자열(String)은 객체이기 때문에, 자바에서는 두 개의 문자열이 서로 같은지 비교할 때 equals() 메소드를 사용한다. 특히, 문자열을 equals()메소드로 비교하게 되면 문자열의 음절 하나씩 같은지 비교하고 또한 음절의 순서도 비교한다. 그래서 자바에서는 문자열이 서로 같은지 정확하게 비교하려면 equals()메소드를 사용하는 것이 맞다. 두 개의 객체를 비교하는 데에 연산자 == 을 사용하게 되면, ==은 두 개의 객체 변수가 같은 객체를 가리키고(refer)있는지 여부를 알려준다.. 2024. 3. 24. 게임으로 배우는 코딩문법 웹 게임으로 배우는 코딩문법 APCSA(자바 AP시험), 파이썬, 기타 코딩 문법을 웹 게임을 하면서 재밌게 공부할 수 있는 사이트를 소개합니다. -링크: https://sites.google.com/view/codinggames/home Computer Science Coding Games Games to Help You Learn Computer Science sites.google.com 2024. 3. 23. [자바기초.025] Simplifying Boolean Using De Morgan's Law [자바기초.025] Simplifying Boolean Using De Morgan's Law 1. 논리 부정 연산자(negation) ! 논리 부정 연산자(negation)는 " ! " 로 사용하며, !(true) = false, !(false) = true와 같이 참과 거짓을 반대로 만든다. 그리고 이런 문장이 있다고 가정하자. "나는 고등학교에 있는 선생님이다." 이 문장에 !(negation) 논리 뷰정 연산자를 사용한다면, "나는 고등학교에 있는 선생님이 아니다" 라고 표현할 수 있다. 그런데, "나는 고등학교에 있는 선생님이 아니다"라는 말은 좀 모호한게, "나는 고등학교가 아니고 다른 중학교나 초등학교를 말하는 건지?", 또는 "나는 고등학교에 있는건 맞는데, 선생님이 아니라는 건지?" 두 .. 2024. 3. 23. [자바AP연습문제]03.Boolean Expressions and If Statements [자바AP연습문제]03.Boolean Expressions and If Statements 문제에 대한 정답은 제일 아래 "더보기" 클릭 *03.Boolean Expressions and If Statements에 대한 복습 내용은 아래 "더보기" 클릭 더보기 In this chapter you learned about conditionals. Conditionals are used to execute code when a boolean expression is true or false. A boolean expression is one that is either true or false like x > 0. Block of statements - One or more statements enclosed.. 2024. 3. 23. [자바기초.024] substring(),toUpperCase(),toLowerCase(),trim() [자바기초.024] substring(),toUpperCase(),toLowerCase(),trim() 1.1 substring() substring()은 문자열을 자르는 명령어 입니다. 1.2 substring() 메소드 사용법 substring() 메소드는 다음과 같이 2가지 형태로 사용할 수 있습니다. substring(int startIndex) 예제 코드 HTML 삽입 미리보기할 수 없는 소스 substring(int startIndex, int endIndex) 예제 코드 HTML 삽입 미리보기할 수 없는 소스 2.1. toUpperCase() 문자열을 모두 대문자(Upper case)로 변환하는 명령어 입니다. 2.2. toUpperCase() 사용법 HTML 삽입 미리보기할 수 없는 소스 .. 2024. 3. 22. [자바AP연습문제]02.Using Objects [자바AP연습문제]02.Using Objects * 2.Using Objects Summary를 복습하려면 아래의 "더보기" 클릭 더보기 In this unit, you learned to use objects (variables of a class type) that have been written for you in Java. You learned to use constructors and methods with and without parameters of objects, and built-in Java classes like String, Integer, Double, and Math. class - defines a new data type. It is the formal implementati.. 2024. 3. 21. [자바AP 연습문제] 01.Primitive Types [자바AP 연습문제] 01.Primitive Types 문제의 정답은 제일 아래 "더보기" 클릭 *Unit.1 Primitive Types Summary를 복습하려면 아래 "더보기" 클릭 더보기 Unit.1 Primitive Types Summary Compiler - Software that translates the Java source code into the Java class file which can be run on the computer. Compiler or syntax error - An error that is found during the compilation. Main method - Where execution starts in a Java program. Variable - A.. 2024. 3. 21. [자바기초.023] 재귀함수 코딩 연습문제 [자바기초.023] 재귀함수 코딩 연습문제 -링크: https://codingbat.com/java/Recursion-1 *문제의 정답은 제일 아래 "더보기" 클릭하시면 확인 가능합니다. [문제1] 아래의 코드에서 "write code here" 부분을 코딩하여, findSum 메소드를 완성하세요. 이 메소드는 변수 n 값과 크기가 같거나 작은 양의 정수의 합을 리턴하는 재귀 메소드 입니다. 예를 들어 findSum(3)은 1+2+3 = 6, 즉 6을 리턴합니다. 아래 예제 코드는 15를 리턴해야 합니다. (Replace the “write code here” below with the code to complete the findSum method. The method should take the su.. 2024. 3. 20. [자바기초.022] 재귀 탐색&정렬(Recursive Searching and Sorting)) [자바기초.022] 재귀 탐색&정렬(Recursive Searching and Sorting) [1] 재귀 이진 탐색(Recursive Binary Search) 1.이진 탐색(Binary Search) 선형 탐색(Linear search)은 배열이나 리스트에 저장된(in order) 데이터를 하나씩 비교하면서 천천히 원하는 데이터를 찾는 알고리즘 입니다. 이진 탐색(Binary search)는 선형 탐색보다 더 빠르게 데이터를 찾는 방법으로서, 정렬된 데이터의 가장 가운데 위치한 것부터 데이터 크기를 비교하여, 비교대상의 절반을 버려가면서 원하는 데이터를 찾는 알고리즘 입니다. Binary search only works on sorted data. HTML 삽입 미리보기할 수 없는 소스 HTML 삽입.. 2024. 3. 20. 이전 1 2 3 4 5 6 7 8 ··· 23 다음 728x90 반응형