Programming/Java28 10 Object-Oriented Programming (feat. Procedural Programming) κ°μ²΄μ§ν₯ νλ‘κ·Έλλ°(Object-Oriented Programming, OOP)μ μννΈμ¨μ΄λ₯Ό μ€κ³νκ³ κ΅¬ννλ λ° μ¬μ©λλ νλ‘κ·Έλλ° ν¨λ¬λ€μ μ€ νλμ λλ€. μ΄ ν¨λ¬λ€μμ νμ€ μΈκ³μ κ°μ²΄(object)μ κ·Έ κ°μ²΄ κ°μ μνΈ μμ©μ μ€μ μ λ‘λλ€. μ¬κΈ°μ κ°μ²΄λ λ°μ΄ν°μ κ·Έ λ°μ΄ν°λ₯Ό μ²λ¦¬νλ λ©μλ(ν¨μ)λ‘ μ΄λ£¨μ΄μ Έ μμ΅λλ€. λ°λ©΄μ μ μ°¨μ§ν₯ νλ‘κ·Έλλ°μ νλ‘κ·Έλ¨μ λ¨κ³μ μΈ μ μ°¨λ‘ λλμ΄ μ€κ³νκ³ , κ° λ¨κ³μμ νμν λ°μ΄ν°λ₯Ό μ²λ¦¬νλ ν¨μ λλ νλ‘μμ λ₯Ό μ€μ¬μΌλ‘ νλ νλ‘κ·Έλλ° ν¨λ¬λ€μμ λλ€. κ°μ²΄μ§ν₯ νλ‘κ·Έλλ°μ λ±μ₯ λ°°κ²½ κ°μ²΄ μ§ν₯ νλ‘κ·Έλλ°(OOP)μ΄ λ±μ₯ν κ²μ μ£Όλ‘ μννΈμ¨μ΄ κ°λ°μμ λ°μνλ 볡μ‘μ±κ³Ό μ μ§λ³΄μμ μ΄λ €μμ λμνκΈ° μν΄μμμ΅λλ€. OOPλ μ μ°¨μ§ν₯ νλ‘κ·Έλλ°μ λ¨μ μ ν΄κ²°.. 2024. 1. 19. 9 Two-dimensional Arrays (Feat. Object Array) 2μ°¨μ λ°°μ΄μ νκ³Ό μ΄λ‘ μ΄λ£¨μ΄μ§ λ°°μ΄λ‘, κ° μμλ λ κ°μ μΈλ±μ€λ‘ μ°Έμ‘°λ©λλ€. μ΄λ νκ³Ό μ΄μ 2μ°¨μ μ’νλ‘ λ°°μ΄ λ΄μ νΉμ μμΉλ₯Ό μ§μ νλ κ²μ λλ€. μλ₯Ό λ€μ΄, νΉμ νκ³Ό μ΄μ μμμ μ κ·Όνκ±°λ κ°μ ν λΉν μ μμ΅λλ€. μ΄ λ°°μ΄μ 3κ°μ νκ³Ό 3κ°μ μ΄λ‘ μ΄λ£¨μ΄μ Έ μμ΅λλ€. κ° νμ μ€κ΄νΈλ‘ λλ¬μΈμΈ λΆλΆμ΄κ³ , κ° νμ λ°°μ΄μ μμλ₯Ό λνλ λλ€. 2μ°¨μ λ°°μ΄μ μ£Όλ‘ νλ ¬(Matrix)λ‘ μ¬μ©λλ©°, μ΄λ₯Ό ν΅ν΄ λ€μν μνμ μ°μ°μ΄λ μ΄λ―Έμ§ μ²λ¦¬μ κ°μ μμ μ μ μ©νκ² νμ©λ©λλ€. λ°°μ΄μ ν¬κΈ°λ κ° νμ κΈΈμ΄κ° λμΌν΄μΌ νλ©°, κ° νλ§λ€ μλ‘ λ€λ₯Έ κΈΈμ΄λ₯Ό κ°μ§ μ μμ΅λλ€. κ°μ²΄ λ°°μ΄(Object Array)μ λ€λ₯Έ λ°μ΄ν° μ ν λμ κ°μ²΄λ₯Ό μμλ‘ κ°λ λ°°μ΄μ λλ€. Javaμμ λͺ¨λ ν΄λμ€λ Ob.. 2024. 1. 19. 8 Array (λ°°μ΄) λ°°μ΄μ λμΌν μ νμ λ°μ΄ν° μμκ° μμλλ‘ μ μ₯λ λ°μ΄ν° ꡬ쑰μ λλ€. κ° μμλ μΈλ±μ€(μΌλ°μ μΌλ‘ 0λΆν° μμ)μ μν΄ μλ³λ©λλ€. λ°°μ΄μ λ°μ΄ν°λ₯Ό ν¨μ¨μ μΌλ‘ μ μ₯νκ³ κ²μνλ λ° μ¬μ©λ©λλ€. μΈλ±μ€(Index): λ°°μ΄μ κ° μμλ κ³ μ ν μΈλ±μ€λ‘ μλ³λ©λλ€. μΌλ°μ μΌλ‘ 0λΆν° μμνμ¬ λ°°μ΄μ κΈΈμ΄λ³΄λ€ νλ μμ κ°κΉμ§μ λ²μλ₯Ό κ°μ΅λλ€. κΈΈμ΄(Length): λ°°μ΄μ κΈΈμ΄λ λ°°μ΄μ ν¬ν¨λ μμμ μλ₯Ό λνλ λλ€. μλ₯Ό λ€μ΄, κΈΈμ΄κ° 7μΈ λ°°μ΄μ 0λΆν° 6κΉμ§μ μΈλ±μ€λ₯Ό κ°λ μΌ κ°μ μμλ‘ κ΅¬μ±λ©λλ€. μ ν(Type): λ°°μ΄μ λμΌν μ νμ λ°μ΄ν° μμλ‘ κ΅¬μ±λλ©°, μλ₯Ό λ€μ΄ μ μ, λ¬Έμμ΄, λΆλ μμμ μ λ±μ΄ λ μ μμ΅λλ€. μ μΈ λ° μ΄κΈ°ν(Declaration and Initialization).. 2024. 1. 19. 7 while loop (feat. do-while) 1. while Loop The while loop is a control flow statement that repeatedly executes a block of code as long as a specified condition is true. 2. do-while Loop The do-while loop is similar to the while loop, but the condition is evaluated after the loop body. This guarantees that the loop body is executed at least once, regardless of whether the condition is initially true or false. 2024. 1. 7. 6 for loop (feat. Nested, foreach) 1. for Loop The for loop in Java is a control flow statement that allows you to repeatedly execute a block of code as long as a certain condition is true. 2. Nested for Loop A nested for loop is a for loop inside another for loop. Example 1 - κ΅¬κ΅¬λ¨ Example 2 3. Enhanced for Loop (foreach Loop) The enhanced for loop, also known as the foreach loop, provides a simpler way to iterate over elements in.. 2024. 1. 7. 5 If & Switch (feat. break, continue) 1) if Statement The if statement is used for making decisions based on a condition. It allows you to execute a block of code if a specified condition evaluates to true. 2) Switch Statement The switch statement is used to select one of many code blocks to be executed based on the value of an expression. It provides a more concise way to handle multiple possible conditions compared to a series of .. 2024. 1. 7. 4 Operation (μ°μ°) μλ°μμ μ°μ°μ(Operators)λ νλ‘κ·Έλ¨μμ λ³μλ κ°λ€ κ°μ μνλλ λμμ λνλ λλ€. μ°μ°μλ νΉμ ν μ°μ°μ μννκ±°λ κ°μ μ‘°μνλ λ° μ¬μ©λ©λλ€. μ°μ°μλ νΌμ°μ°μ(Operands)λΌ λΆλ¦¬λ νλ μ΄μμ κ°μ νμλ‘ νλ©°, νΌμ°μ°μμ μ°μ°μ κ°μ μ‘°ν©μΌλ‘ ννμμ νμ±ν©λλ€. μ°μ°μμ μ¬λ¬κ°μ§ μ’ λ₯ 1. μ¦κ° μ°μ°μ (Increment, Decrement Operators) μ¦κ° λ° κ°μ μ°μ°μλ λ°λ³΅λ¬Έμμ μμ£Ό μ¬μ©λλ©°, λ³μμ κ°μ μ¦κ°μν€κ±°λ κ°μμν¬ λ νΈλ¦¬νκ² νμ©ν μ μμ΅λλ€. κ·Έλ¬λ μ¬μ©ν λ μ£Όμκ° νμνλ©°, νΉν λ€λ₯Έ μ°μ°μμ ν¨κ» μ¬μ©λ λ μ°μ μμμ μ£Όμν΄μΌ ν©λλ€. 2. μ°μ μ°μ°μ (Arithmetic Operators) 3. λΉκ΅ μ°μ°μ (Comparison Op.. 2023. 12. 30. 3 Casting Javaμμ Castingμ λ³μλ ννμμ λ°μ΄ν° μ νμ λ€λ₯Έ λ°μ΄ν° μ νμΌλ‘ λ³ννλ νλ‘μΈμ€λ₯Ό λνλ λλ€. μ΄λ μλ‘ λ€λ₯Έ μ ν κ°μ ν λ³νμ μννλ λ° μ¬μ©λ©λλ€. Javaμμλ λ κ°μ§ μ νμ μΊμ€ν μ΄ μμ΅λλ€. 1) Widening Casting (automatically) - converting a smaller type to a larger type siz byte - short - char - int - long - float - double 2) Narrowing Casting (manually) - converting a larger type to a smaller size type double - float - long - int - char - short - byte Casti.. 2023. 12. 29. 2 Variable, Constant and Primitive Type in Java (Feat. Literal) λ³μ (Variables) λ³μλ λ°μ΄ν°λ₯Ό μ μ₯νκ³ μ°Έμ‘°νκΈ° μν λ©λͺ¨λ¦¬ 곡κ°μ μ΄λ¦μ λλ€. λ³μλ μ μΈλ λ°μ΄ν° νμ μ λ§κ² κ°μ μ μ₯ν μ μμ΅λλ€. κ°μ μΈμ λ μ§ λ³κ²½λ μ μμ΅λλ€. μμ (Constants) μμλ νλ‘κ·Έλ¨ λ΄μμ λ³νμ§ μλ κ°μΌλ‘, ν λ² ν λΉλλ©΄ λ³κ²½ν μ μμ΅λλ€. μλ°μμλ final ν€μλλ₯Ό μ¬μ©νμ¬ μμλ₯Ό μ μΈν©λλ€. μμλ λ³΄ν΅ λλ¬Έμλ‘ λͺ λͺ λλ©°, μ¬λ¬ λ¨μ΄μ μ‘°ν©μΌ κ²½μ° μΈλμ€μ½μ΄ _ λ‘ μ°κ²°λμ΄ μ§λλ€. κΈ°λ³Έ λ°μ΄ν° νμ (Primitive Data Types) μλ°μμλ κΈ°λ³Έ λ°μ΄ν° νμ μΌλ‘ λ€μν μ’ λ₯κ° μ 곡λ©λλ€. μ΄λ¬ν κΈ°λ³Έ λ°μ΄ν° νμ μ λ©λͺ¨λ¦¬λ₯Ό ν¨μ¨μ μΌλ‘ μ¬μ©νλ©°, λ€μν λ°μ΄ν° μ νμ μ§μν©λλ€. 1) μ μν (Integer Types) byte: .. 2023. 12. 29. μ΄μ 1 2 3 4 λ€μ