2020-02-28 TIL

할 일 목록

  • 웹지탱 완독
  • 부동 소수점에 대해서 정리한다.
  • Expressions, Statements, and Blocks 정리

완료하지 못한 목록

완료 목록

  • 웹지탱 완독

5Fs

1. Fact

쟈바의 Expressions, Statements, and Blocks

Expressions

Expresion은 variables, operators, method invocations 들로 이루어진 construct 이며 하나의 단일 값 이다.

expression으로 인해 반한된 value의 data type은 expression에서 사용된 elements에 결정된다. cadence = 0 은 cadence가 int이고 assignment operator가 cadence와 동일한 데이터 유형의 값을 반환한다. 다른 expressions에서도 cadence 가 boolean 또는 String 타입이라면 cadence의 데이터타입의 값을 리턴한다.

java는 표현식들의 데이타 타입이 일치한다면 밑의 코드와 같이 여러 작은 표현식들을 사용하여 복합적인 expressions를 만들 수 있다.

1 * 2 * 3

expression을 사용할 땐 연산자 우선순위를 고려해야한다. 그렇기 때문에 명확하게 사용하기 위해서 bracket을 명시적으로 표시해줘야한다.

Statements

statements는 실제 언어로 사용하는 문장들과 거의 비슷하다. statement 한 완전한 실행 유닛을 형성한다. 밑에있는 종류의 expression 세미콜론을 사용하여 표현식을 종료하고 statement로 만들 수 있다.

  • Assignment expreesions
  • Any use of ++ or —
  • Method invocations
  • Object creation expression

밑의 statements 들은 expression statement라고 불린다

// assignment statement
aValue = 8933.234;
// increment statement
aValue++;
// method invocation statement
System.out.println("Hello World!");
//object creation statement
Bicycle myBike = new Bicycle();

추가적으로 expression statements에는 declaration statements와 control flow statements 가 존재한다.

declaration statement 는 변수를 선언한다.

// declaration statement
double aValue = 8933.234;

코드는 위에서 아래로 순서대로 실행이 된다. 하지만 control statements는 branch와 looping을 만들어 프로그램이 상태에 따라 실행이 되도록 한다.

decision-making statements

  • if -then
  • if -then-else
  • switch

looping statements

  • for
  • while
  • do-while

branch statements

  • break
  • continue
  • return
Blocks

block은 중괄호 사이에 0개 이상의 statement로 구성된 그룹이며 단일 문이 허용되는 모든곳에서 사용할 수 있다.

class BlockDemo {
     public static void main(String[] args) {
          boolean condition = true;
          if (condition) { // begin block 1
               System.out.println("Condition is true.");
          } // end block one
          else { // begin block 2
               System.out.println("Condition is false.");
          } // end block 2
     }
}

2.Feelings

  • 코로나가 점점 더 심해져서 파주로 왔다. 근데 오늘 너무 띵가띵가 놀아버렸다.. 내일부터 열심히 해야하는데 할 수 있을까 여자친구가 부른다.
  • 대대적인 방 청소를 하였는데 집이 꽤 쾌적해져서 기분이 좋다.

3.Findings

4.Future Action Plan

5.FeedBack


Written by@Zero1
This blog is for that I organize what I study and my thinking, feeling and experience.

GitHub