WIL(What I Learned) (78) 썸네일형 리스트형 Java Enhanced For Loop(자바 향상된 반복문) 문법: for(dataType item : array) { ... } array - an array or a collection item - each item of array/collection is assigned to this variable dataType - the data type of the array/collection Ex.1> // print array elements class Main { public static void main(String[] args) { // create an array int[] numbers = {3, 9, 5, -5}; // for each loop for (int number: numbers) { System.out.println(number); } } .. 호눅스 클래스/메서드 분리 댓글 좋은 글 쓰는 거랑 비슷해요 다른 사람의 코드를 많이 읽어 보고 많이 짜 보는 것 외에는 방법이 없어 보입니다 일단 한글로 주석을 달아 보세요 메서드 설명이 두 줄이면 분리해야 하고 클래스 설명이 두 줄이면 분리해야겠죠 Push 전 Commit 메시지 변경하기 Commit has not been pushed online If the commit only exists in your local repository and has not been pushed to GitHub.com, you can amend the commit message with the git commit --amend command. On the command line, navigate to the repository that contains the commit you want to amend. Type git commit --amend and press Enter. In your text editor, edit the commit message, and save the commit. http.. 21.11.29 月 Print a type of Java variable String name = theVariable.getClass().getSimpleName(); if 조건문에서 == 대신 .equals()를 쓰기도 한다. String to Integer conversion Example. int i=Integer.parseInt("200"); Primitive Data Types. The eight primitives defined in Java are int, byte, short, long, float, double, boolean, and char – those aren't considered objects and represent raw values. Honux 조언 여러분 마지막으로 잔소리를 한 번 하려고 하는데요. 여러분 깃헙을 보니까 잔디가 안 심어진 날이 많아요. 개인적으로 깜짝 놀랐는데 어떤 이유든지 코딩을 한 줄도 안 한 날 혹은 커밋이 하나도 없는 날이 있다는게 의아합니다. 여러분이 개발자를 목표로 하고 있다면 1년 정도는 매일 코딩 - 혹은 일요일을 제외한 주 6회 코딩 정도 - 는 의도적으로 하도록 시도해 보세요. 루틴을 만들면 정말 학습에 도움이 됩니다.매일 함수 하나, 알고리즘 한 문제 정도는 풀어 보세요. 21.11.26 金 A constructor in Java is a special method that is used to initialize objects. If a class has no modifier (the default, also known as package-private), it is visible only within its own package (packages are named groups of related classes — you will learn about them in a later lesson.) https://stackoverflow.com/questions/16164902/what-is-the-default-access-modifier-in-java 21.11.22 月 자바 배열 오름차순 정렬 Arrays.sort(array_name) 자바 배열 인덱스로 요소 얻기 array[index] 이때 맨 마지막 요소를 얻으려면 array.length - 1로 인덱싱해야 함에 유의. 자바정석 Chap.6 연습문제 답안 확인 모음 6-4) 어떤 int값을 특정 int값으로 나눠서 소수점 아래의 숫자가 포함된 결과를 얻으려면 float 타입의 리터럴로 나눠야 한다. 리터럴이란 '상수(constant; 값을 한번만 저장할 수 있는 공간)'의 다른 이름이다. 어떤 float 값을 소수점 아래 첫째자리까지 반올림할 수 있는 기법으로는 그 float 값에다 10을 곱하고 0.5를 더한 뒤 int로 형변환을 하고 10f로 나눠주는 것이다. 이것을 소수점 아래 n번째자리까지 반올림할 때 응용할 수 있을 것이다. 이때 형변환(Casting)을 하기 위해서는 다음과 같이 하면된다. (타입)피연산자 6-5) 메서드 반환 타입이 String이어도 String 타입이 아닌 변수나 메서드를 반환문에 포함시켜도 됨을 확인했다. public String i.. 이전 1 2 3 4 5 6 7 ··· 10 다음