본문 바로가기
반응형

자바(Java)64

[자바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.
[자바기초.021] 재귀 함수 실행(Tracing Recursive Methods) [자바기초.021] 재귀 함수 실행(Tracing Recursive Methods) [1] Tracing Recursive Methods 자바에서는 call stack이라는 것이 실행된 메소드들을 추적합니다. 스택(stack)이라는 것이 무엇인지 알아야 재귀함수(Recursive method) 실행과정을 이해할 수 있습니다. [2] 스택(stack) 스택은 LIFO(Last In First Out) 원칙을 따르는 선형 데이터 구조입니다. 이는 스택 내부에 삽입된 마지막 요소가 먼저 제거됨을 의미합니다. 자바에서는 위와 같은 stack구조로 메소드가 저장되고 실행되는 것을 call stack 이라고 부릅니다. 위 그림에서는 다음을 수행할 수 있습니다. 1.stack안에 새 데이터를 넣기 2.상단 데이터 제.. 2024. 3. 17.
[자바기초.020] 재귀(Recursion) [자바기초.020] 재귀(Recursion) [1] 재귀(Recursion) 이란? 재귀는 "원래 자리로 되돌아 온다"라는 뜻이다.(두 "재": 재차, 두 번, 다시 한번 / 돌아갈 "귀": 돌아가다) 자바에서는 "재귀함수(Recursive method)"라는 말로 사용되고, 함수 자기 자신을 다시 실행시키는 형태를 말한다. [예제1] 재귀 함수의 아래 예시 코드를 보자. HTML 삽입 미리보기할 수 없는 소스 위 코드에서 재귀함수를 실행하는 부분(함수 자신을 다시 call 하는 부분)은 몇 번째 줄이가요? => ( 4 번째 줄) 위의 코드는 글자를 출력하고 다시 자기 자신을 계속 호출(실행)하는 함수이다. 그래서 이 함수는 무한 재귀(infinite recursion)으로서 실행에 끝이 없다. 따라서 .. 2024. 3. 17.
[자바기초.019] Object Superclass [자바기초.019] Object Superclass [1] Object Superclass 자바에서 Object class는 다른 모든 클래스의 superclass입니다. Object 클래스에는 여러가지 메소드가 있는데, 그 중에서 AP CSA 시험에서 강조하는 2가지 메소드( toString, equals )에 대해서 알아보겠습니다.(아래는 AP CSA시험에서 제공하는 Java Quick Reference입니다.) [2] toString( ) 메소드 Object 클래스 중에 오버라이드(Override)를 많이 하는 메소드 중의 하나로, toString()이 있습니다. toString()메소드는 객체(object)의 특성을 출력하는 데에 많이 사용됩니다. 내가 만든 클래스에서 toString()을 오버라.. 2024. 3. 17.
728x90
반응형