목록전체 글 (89)
develope_kkyu
public static void main(String[] args) { // 1. 제네릭을 사용하지 않았을 경우의 케이스. ==> 데이터의 타입을 확인하면서 강제타입변환을 필요하였음. List list1 = new ArrayList(); // List는 인터페이스, ArrayList는 구현클래스. list1.add("HUMAN1"); list1.add("HUMAN2"); list1.add(10); // 위의 형태로 문자와 숫자가 같이 담겨있을 수 있는 이유는 // Object의 형태이기 때문에 가능함. String str1 = (String) list1.get(0); // list1.get(0) ==> 되돌려주는 값의 타입. Object // Object 클래스는 모든 클래스의 최상위 타입임. // S..
import java.time.DayOfWeek; import java.time.LocalDateTime; import java.time.temporal.TemporalAdjusters; public class DateTimeOperatinExam { public static void main(String[] args) { LocalDateTime now = LocalDateTime.now(); System.out.println("현재시간 : " + now.toString()); // 날짜, 시간의 연산 LocalDateTime targetDateTime1 = now.plusYears(1).minusMonths(2).plusDays(3).plusHours(4).minusMinutes(5).plusSeco..
import java.time.Duration; import java.time.LocalDateTime; import java.time.Period; import java.time.temporal.ChronoUnit; public class DateTimeCompareExam { public static void main(String[] args) { LocalDateTime startTime = LocalDateTime.of(2023, 1, 1, 9, 0, 0); LocalDateTime endTime = LocalDateTime.of(2024, 12, 31, 23, 59, 59); System.out.println("시작시간 : " + startTime); System.out.println("종료시간..
import java.util.Calendar; public class CalenderExam { public static void main(String[] args) { Calendar now = Calendar.getInstance(); //System.out.println (now); System.out.println (now.toString()); int year = now.get(Calendar.YEAR); // 2022 int month = now.get(Calendar.MONTH) + 1; // Calendar.MONTH는 0에서부터 시작 ==> 9 int day = now.get(Calendar.DAY_OF_MONTH); // 21 int week = now.get(Calendar.DAY_..
Accoung.java public class Account { private String ano; private String owner; private int balance; private int password; public Account(String ano, String owner, int balance, int password) { this.ano = ano; this.owner = owner; this.balance = balance; this.password = password; } public String getAno() { return ano;// this.ano } public void setAno(String ano) { this.ano = ano; } public String getO..
Account.java public class Account { private String ano; private String owner; private int balance; public Account(String ano, String owner, int balance) { this.ano = ano; this.owner = owner; this.balance = balance; } public String getAno() { return ano;// this.ano } public void setAno(String ano) { this.ano = ano; } public String getOwner() { return owner;// this.owner } public void setOwner(Str..
두 주사위 눈의 합이 5가 나올 때까지 실행 public static void main(String[] args) { for(int i = 0; i 5
public static void main(String[] args) { // for문은 활용하여 1~100까지의 누적합 구하기. int total = 0; int index;// for문 밖에서 index를 사용하는 부분이 있기 때문에 변수 선언은 for문 밖에서 사용. for (index=1; index 초기값을 설정 // index 반복에 대한 조건. // index++ ==> for문 마감시 처리하는 실행문 total = total + index; System.out.printf("%d번째까지의 누적합 %d입니다. \n", index, total); } System.out.printf("index = %d \t total=%d \n", index-1, total); } -- 1번째까지의 누적합 1..
public static void main(String[] args) { // 점수가 60점 이상이면 합격, 그 중에서도 90점 이상일 경우 장학생여부 판별하는 프로그램 // 60점 이하면 불합격 그 중에서도 40점 이하일 경우는 5년내 시험 자격불가 int score = 40; System.out.printf("score = %d \n", score); if (score >= 60) { // 60보다 클 경우 실행문 System.out.println("당신은 합격하셨습니다."); if (score >= 90) { // 90보다 클 경우 장학생에 관련 로직 System.out.println("당신은 장학생이 되셨습니다."); } else { System.out.println("아쉽게도 장학생은 아닙니다...
public static void main(String[] args) { int human1 = 99; int result1 = ++human1 * 10; //위 한줄은 아래 2줄과 같은 의미임. // human1 = human+1;==> human1 = 100; // int result1 = human1 * 10;==> result1 = 1000; System.out.printf("human1 = %d, result1 = %d \n", human1, result1); int human2 = 99; int result2 = human2++ * 10; // int result2 = human2 * 10;==> result2 = 990; // human2 = human2 + 1;==> human2 = 100..