INTRODUCTION TO JAVA

Whitespace 공백

Before we explore what we can do with variables, let’s learn how to keep code organized in Java.

변수로 무언가를 할 수 있는가를 보기 전에, 자바에서 코드가 어떻게 정돈되는지 봅시다.

Whitespace is one or more characters (such as a spacetabenter, or return) that do not produce a visible mark or text. Whitespace is often used to make code visually presentable.

공백은 눈에 보이지 않는 하나 혹은 그 이상 캐릭터(스페이스 바, 탭, 엔터, 백스페이스 등) 문자를 말합니다.

공백은 코드가 눈에 보기 좋게 하기 위해서 자주 사용됩니다.

Java will ignore whitespace in code, but it is important to know how to use whitespace to structure code well. If you use whitespace correctly, code will be easier for you and other programmers to read and understand.

자바 언어는 코드에서 공백을 무시하는데, 공백을 어떻게 쓰는 지를 알고 있는 것은 코드를 잘 짜기 위해서는 중요하빈다. 공백을 잘 쓸 수 있게 되면, 코드는 어떤 프로그래머가 읽어도 보기 쉽고 이해하기 쉽게 작성될 수 있습니다.


public class WhiteSpace {

public static void main(String[] args) {


 char isFormatted = ' ';   // 캐릭터 이름 isFormatted에 space 하나가 저장되어 있음.

    System.out.println(isFormatted);   // 출력 스페이스 한개 그리고 자동 엔터(줄 바꿈)

    System.out.println(" ");                // 문자열 스페이스 한개 그리고 자동 엔터(줄 바꿈) 출력

                string a = " ";  // a라는 string data type 변수에 " " 스페이스 한개 저장

    System.out.println(a);     // a string 변수 출력 , " " 그리고 줄바꿈 출력

}

}

위 코드를 run or execute 하게되면 어떤 결과가 나올까요? 상상해보셨나요?

아마 아무것도 나타나지 않을 것입니다. 아무 것도 화면에 안나왔다면 코드를 올바르게 작성하신 것입니다.

+ Recent posts