Skip to content

Latest commit

 

History

History

jeongwoo

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Programming in the Small 1 : Names and Things

optional-package-declaration optional-imports public class program-name{ optional-variable-declarations-and-subroutines public static void main(String[] args){ statements } optional-variable-declarations-and-subroutines }

semantics(의미론)

  • 코더가 의미하는 바

syntax(구문)

  • 코드의 문법(작성 규칙)

2.2 Variable and the Primitive Types

Variables

  • A name used in this way-to refer to data stored in memory-is called a variable.

variable = expression;

Types

8 primitive types
  • byte

  • short

  • int

  • long

  • float

  • double

  • char

  • boolean

Literals

  • It is a kind of name for a constant value

Program’s Variables

  • local variables

  • parameter

2.3 Strings, Classes, Objects, and Subroutines

Built-in Subroutines and Functions

  • 우리가 사용하는 함수들도 사실 서브루틴이다. ex) System.out.print(), Math.sqrt()

  • 우리는 평소에도 서브루틴을 모른채 사용하고 있다. - BlackBox Test

Static Members

  • 클래스의 목적 중 하나는 해당 클래스에 포함된 일부 변수와 서브루틴을 그룹화

  • System이라는 표준 클래스, Exit라는 Subroutines에, Subroutines에 사용하는 parameter

  • Math.sqrt(x) 한 줄의 코드는 불가능, 반환값을 가지기 때문에 값 자체이다.

Classes and Objects

  • int double이 type처럼 Classes는 유형이다.

  • 한 가지 유형의 값만 보유할 수 있다 → 객체

Operation on String

  • equlas 두 문자열 비교

  • eualsIgnoreCase 대문자 소문자는 동일

  • length 길이

  • charAt 문자로 반환

  • subString 문자열 자르기

  • indexOf 정수로 반환

  • compareTo 알파벳 순서에 따라

  • toUpperCase 대문자 변환

  • tolowerCase 소문자 변환

  • trim 끝의 공백을 제거 === Text Bolocks \n === Enums

  • 열거형 상수

    enum enum-type-name { list-of-enum-values}
    enum Day{SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY}

2.4 Text Input and Output

-