Git Clone : remote를 local repository로 가져오는 것
local repository : 내 PC or 서버
remote repository : 인터넷 상에 있는 레퍼지토리
(local이 clone 명령어 실행)
(remote는 Github, Bitbucket, AWS)
ls : 사용자의 PC 디렉토리 목록(Home 디렉토리)
mkdir git : 현재 디렉토리에 git 디렉토리 생성
cd git : git 디렉토리로 이동
git clone [주소] : 주소는 GitHub사이트로 이동하여 원하는 레퍼지토리 복사
(주소 복사시 Shift+Insert)
git log : 히스토리 보기
🟢 터미널에서 hello내용을 가진 txt파일 생성
echo hello > hello.txt
🟢 내용확인
cat hello.txt
🔴 commit 전 설정(무시 설정)
public class ArrayTest {
public static void main(String[] args) {
int[] arr = new int[10];
for(int i = 0; i < 10; i++) {
arr[i] = (i + 1);
}
for(int tmp : arr){
System.out.println(tmp);
}
}
}
import java.util.Scanner;
public class PrintChange {
public static void main(String[] args) {
int[] arrs = {50000, 10000, 5000, 1000, 500, 100, 50, 10};
System.out.print("금액을 넣으세요:");
Scanner sc = new Scanner(System.in);
int money = sc.nextInt();
int tmp;
for(int arr : arrs) {
tmp = money / arr;
money %= arr;
System.out.println(arr + "원? " + tmp + "개");
}
}
}
🟢 arrs로 나누는 값을 배열화하여 코드 간결화
정수 두개가 입력으로 들어온다.
만약 첫번째 정수가 홀수이면 "홀수"를 출력하고, 짝수이면 "짝수"를 출력한 후 "+"를 출력한다.
그리고 두번째 정수가 홀수이면 "홀수"를 출력하고, 짝수이면 "짝수"를 출력한 후 "="을 출력하고 결과로 나오는 값이 홀수인지 짝수인지 출력한다.
import java.util.Scanner;
public class Main {
private String isEven(int num){
if(num % 2 == 0){
return "짝수";
} else {
return "홀수";
}
}
public static void main(String[] args) {
Main main = new Main();
Scanner sc = new Scanner(System.in);
int num1 = sc.nextInt();
int num2 = sc.nextInt();
System.out.print(main.isEven(num1) + "+");
System.out.print(main.isEven(num2) + "=");
System.out.print(main.isEven((num1+num2)));
}
}
🟢 Main main = new Main() : Main 클래스 객체를 생성하여 함수를 호출할 수 있도록 함
🟢 반복되는 코드를 함수화하여 간결화