-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chapter 09 : 자바를 배우면 패키지와 접근 제어자는 꼭 알아야 해요
공부 내용 정리 완료
- `chapter 09 : 자바를 배우면 패키지와 접근 제어자는 꼭 알아야 해요` 공부 내용 정리 완료 - 이전 틀린 문서 형식, 틀린 내용 수정 - `Run Java`, `Build Java`, `Clean Java class file task` 추가 --- <<< 공부 내용 동기화 `commit` <<< Merge remote-tracking branch `origin/main` into test <<< 공부 내용 동기화 `commit` (#16) <<< Merge branch `main` into `test` <<< 문맥 수정 <<< 문단 형식 개선 ---
- Loading branch information
Showing
15 changed files
with
456 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@echo off | ||
|
||
@REM Usage: get_package_name.bat <relative_path_to_java_file> | ||
|
||
set "java_file=%1%" | ||
|
||
@REM Convert path separators to dots | ||
set "package_name=%java_file:\=.%" | ||
|
||
@REM Remove ".java" extension | ||
set "package_name=%package_name:.java=%" | ||
|
||
echo %package_name% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type" : "java", | ||
"name" : "Debug java", | ||
"request" : "launch", | ||
"mainClass" : "${file}", | ||
"console" : "integratedTerminal", | ||
"cwd" : "${workspaceFolder}", | ||
"internalConsoleOptions" : "neverOpen", | ||
} | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"workspaceKeybindings.CustomTasks.enabled": true | ||
} | ||
// User >> keybindings.json | ||
// [ | ||
// { | ||
// "key" : "ctrl+shift+j", | ||
// "command" : "workbench.action.tasks.runTask", | ||
// "when" : "config.workspaceKeybindings.CustomTasks.enabled", | ||
// "args" : "Run Java" | ||
// }, | ||
// { | ||
// "key" : "ctrl+shift+i", | ||
// "command" : "workbench.action.tasks.runTask", | ||
// "when" : "config.workspaceKeybindings.CustomTasks.enabled", | ||
// "args" : "Clean Java class files" | ||
// } | ||
// ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
|
||
// List of variables in VsCode : | ||
// https://code.visualstudio.com/docs/editor/variables-reference | ||
|
||
"version" : "2.0.0", | ||
|
||
// basics for general | ||
"type" : "shell", | ||
"options" : {"cwd" : "${workspaceFolder}"}, // should be project's directory | ||
"problemMatcher": [], | ||
|
||
// terminal properties for each platform | ||
"windows" : {"options": {"shell": { | ||
"executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", // absolute path to Powershell | ||
"args" : [ | ||
"-NoProfile", | ||
"-ExecutionPolicy", | ||
"Bypass", | ||
"-Command" | ||
]}}}, | ||
"linux" : {}, | ||
"osx" : {}, | ||
|
||
// revealing options for general | ||
"presentation" : { | ||
"echo" : true, | ||
"reveal" : "always", | ||
"focus" : true, | ||
"panel" : "shared", | ||
"showReuseMessage" : true, | ||
"clear" : false, | ||
"revealProblems" : "onProblem" | ||
}, | ||
"promptOnClose" : false, | ||
|
||
"tasks" : [ | ||
{ | ||
"label" : "Build Java", | ||
"group" : "build", | ||
|
||
"command" : "javac", | ||
"args" : [ | ||
"-g", | ||
"${file}" | ||
], | ||
|
||
"detail" : "Compile current Java file", | ||
"icon" : { | ||
"id" : "file-code", | ||
"color" : "terminal.ansiBlue" | ||
}, | ||
}, | ||
|
||
{ // Keyboard Shortcuts : cmd + shift + J | ||
"label" : "Run Java", | ||
"group" : "build", | ||
|
||
"command" : "java", | ||
"dependsOn" : ["Build Java"], | ||
|
||
// CLI for window powershell | in window, `\` is used as separator, causing `java.lang.NoClassDefFoundError` | ||
"windows" : { | ||
"command" : "${workspaceFolder}${/}.vscode${/}ChangeSeparator.bat", // use `ChangeSeparator.bat` to convert separator like unix | ||
"args" : [ | ||
"${relativeFileDirname}/${fileBasenameNoExtension}", | ||
"|", | ||
"ForEach-Object", | ||
"{", | ||
"java", | ||
"$_", | ||
"}" | ||
], | ||
}, | ||
|
||
// CLI for unix shell | in unix, `/` is used as separator | ||
"linux" : {}, "osx" : {}, | ||
"args" : ["${relativeFileDirname}/${fileBasenameNoExtension}"], | ||
|
||
"presentation" : {"clear": true}, // clear terminal before execution | ||
"detail" : "Compile & Execute current Java file", | ||
"icon" : { | ||
"id" : "run-all", | ||
"color" : "terminal.ansiGreen" | ||
} | ||
}, | ||
|
||
{ // Keyboard Shortcuts : cmd + shift + I | ||
"label" : "Clean Java class files", | ||
"group" : "none", | ||
|
||
// CLI for window powershell | ||
"windows" : { | ||
"command" : "Get-ChildItem", | ||
"args" : [ | ||
"${workspaceFolder}", | ||
"-Recurse", | ||
"|", | ||
"Where{$_.Name", | ||
"-Match", | ||
"'class'}", | ||
"|", | ||
"Remove-Item" | ||
] | ||
}, | ||
|
||
// CLI for unix shell | ||
"linux" : {}, "osx" : {}, | ||
"command" : "find", | ||
"args" : [ | ||
"${workspaceFolder}", | ||
"-name", | ||
"\\*.class", | ||
"-type", | ||
"f", | ||
"-delete" | ||
], | ||
|
||
"detail" : "Clean every Java class files in Working Directory", | ||
"icon" : { | ||
"id" : "clear-all", | ||
"color" : "terminal.ansiCyan" | ||
}, | ||
} | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
|
||
Project_directory = ~/Desktop/Coding/God_of_java_practice | ||
Practice_directory = ${Project_directory}/Practice | ||
Scripts_directory = ${Project_directory}/scripts | ||
Code_directory = ${Scripts_directory}/*/code | ||
|
||
clean: | ||
rm -rf ${Practice_directory}/*.class ${Code_directory}/*.class | ||
find ${Project_directory} -name \*.class -type f -delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
### Chapter 09 : 자바를 배우면 패키지와 접근 제어자는 꼭 알아야 해요 | ||
|
||
- [`1. 패키지는 그냥 폴더의 개념이 아니에요`](./section_01_04.md) | ||
- [`2. 패키지 이름은 이렇게 지어요`](./section_01_04.md) | ||
- [`3. import 를 이용하여 다른 패키지에 접근하기`](./section_01_04.md) | ||
- [`4. 자바의 접근 제어자`](./section_01_04.md) | ||
|
||
--- | ||
|
||
### What I learned from this chapter | ||
|
||
이번 챕터에서는 `Java` 의 `package` 에 관해 배웠다. | ||
|
||
애초에 큰 관점에서 봤을 때, 다른 언어의 모듈, 라이브러리와 다른 점이 없기에 어려운 점은 없었다. | ||
다만 세부적으로 봤을 때, 어느 클래스들이 같은 `package` 에 속해있으면 참조 가능하다는 점, `import` 구문은 `class body` 속에 선언될 수 없다는 점 등이 달랐다. | ||
|
||
그리고 내용이 조금 널널한 김에 `Run Java`, `Clean Java class files` 같은 `task` 를 만들었다. 이를 단축키로 지정했고 좀 더 편하게 공부할 수 있을 것 같다. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
### Chapter 09 : 자바를 배우면 패키지와 접근 제어자는 꼭 알아야 해요 - 정리해 봅시다. | ||
|
||
- `[1]` : `godofjava` 폴더 아래에 `b` 라는 폴더를 만들자. | ||
- `[2]` : `b` 폴더 아래에 `array`, `control`, `operator`, `variable` 이라는 폴더를 만들자. | ||
- `[3]` : `ArrayMain.java` 파일을 `godofjava/b/array` 폴더로 옮기자. | ||
- `[4]` : `ArrayMain.java` 파일을 열어 `b.array` 라는 패키지로 선언하자. | ||
- `[5]` : `ArrayMain` 클래스가 제대로 컴파일 되는지 확인해 보자. | ||
- `[6]` : `b.control` 폴더에는 `ControlIf`, `b.operator` 폴더에는 `OperatorConditional`, `b.variable` 폴더에는 `VariableTypes` 클래스를 각각 이동하고, 패키지를 선언한 뒤 컴파일해 보자. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package scripts.ch_09.code.b.array; | ||
|
||
// file compiles successfully | ||
|
||
public class ArrayMain { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package scripts.ch_09.code.b.control; | ||
|
||
// file compiles successfully | ||
|
||
public class ControIf { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package scripts.ch_09.code.b.operator; | ||
|
||
// file compiles successfully | ||
|
||
public class OperatorConditional { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package scripts.ch_09.code.b.variable; | ||
|
||
// file compiles successfully | ||
|
||
public class VariableTypes { | ||
public static void main(String[] args) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
### Chapter 09 : 자바를 배우면 패키지와 접근 제어자는 꼭 알아야 해요 - 정리해 봅시다. | ||
|
||
- [`문제 설명`](./README.md) | ||
|
||
--- | ||
|
||
문제에서 제시한 그대로 만들면 된다. | ||
다만 `"정리해 봅시다"` 중 `import 는 클래스 내에 선언해도 되나요?` 문항이 있는데, 이는 사용될 수 없다. |
Oops, something went wrong.