일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- https://minkwon4.tistory.com/161
- https://tecoble.techcourse.co.kr/post/2021-08-07-logback-tutorial/
- 국회의원 & 높으신 분들 어록
- Today
- Total
목록java (56)
OPEN between Secret
public class Book { String title; String author; int ISBN; public Book(String title, String author, int ISBN) { this.title = title; this.author = author; this.ISBN = ISBN; System.out.println(title + author + ISBN); } public Book(String title, int ISBN) { this(title, "Anonymouse" , ISBN); } public Book(){ this(null, null, 0); System.out.println("생성자가 호출되었음;"); } public static void main(String [] ..
public class ArrayParameter { static void replaceSpace(char a[]){ for(int i = 0; i
import java.io.*; class Yuen2 { int cnt1=0, cnt2=0; boolean b1 = true; public void Calc() { while(true) { try{ int i = System.in.read(); if(i == 32){ if(b1 == true){ cnt1 +=1; b1 = false; } else if(b1 == false) { cnt2 +=1; b1 = true; } } else if(i == 13){ System.out.println("left" + cnt1); System.out.println("right" +cnt2); System.out.println("총 합계" + (cnt1 + cnt2)); break; } }catch(Exception e)..
import java.awt.*; import java.awt.event.*; class Yuen extends Frame { int cnt1 = 0; int cnt2 = 0; boolean bl = true; TextArea ta; public Yuen () { setLayout(new FlowLayout() ); Panel p1 = new Panel(); Label la1 = new Label("스페이스바 입력 개수 출력하기 "); p1.add(la1); add(p1); Panel p2 = new Panel(); ta = new TextArea( "",5, 20,TextArea.SCROLLBARS_NONE); p2.add( ta ); add( p2 ); ta.addKeyListener( new Key..
import java.util.Scanner; class Goods { private String name; private int price; private int numberOfStock; private int sold; Goods(String name, int price, int numberOfStock, int sold) { this.name = name ; this.price = price; this.numberOfStock = numberOfStock; this.sold = sold; } String getName() { return name; } int getPrice () { return price; } int getNumberOfStock(){ return numberOfStock; } i..
public class MyExp { int base; int exp; int getValue() { int res=1; for(int i = 0 ; i < exp ; i++) res = res * base; return res; } public static void main(String[] args){ MyExp num = new MyExp(); num.base = 2; num.exp = 3; MyExp num2 = new MyExp(); num2.base = 3; num2.exp = 4; System.out.println("2의 3승 = " + num.getValue()); System.out.println("3의 4승 = " + num2.getValue()); } } -----------------..
public class Goods { String name; int price; int numberOfStock; int sold; public static void main(String[] args){ Goods camera = new Goods(); camera.name = "Nikon"; camera.price = 400000; camera.numberOfStock =30; camera.sold = 50; System.out.println(camera.name); System.out.println(camera.price); System.out.println(camera.numberOfStock); System.out.println(camera.sold); } } --------------------..
import java.util.Random; import java.util.Scanner; public class CardGame { public static void main (String [] args) { Random rd = new Random(); Scanner sc = new Scanner(System.in); while(true) { int low = 0; int high = 99; int i = 1 ,num = 0; int card = rd.nextInt(100); System.out.println("수를 결정하였습니다. 맞추어보세요"); if(num >high || num < low){ System.out.println("범위를 벗어났습니다."); } else { while(true) {..
public class ArrayException { public static void main (String [] args){ int [] intArray = new int[5]; intArray[0] = 0; try { for (int i = 0 ; i < 5 ; i ++) { intArray[i+1] = i+1 + intArray[i]; System.out.println("intArray["+i+"]" + "=" + intArray[i]); } } catch(ArrayIndexOutOfBoundsException e) { System.out.println("배열의 인덱스가 범위를 벗어났습니다."); } } } --------------------------------------------------..
import java.util.Scanner; public class ExceptionExcample1 { public static void main (String [] args) { Scanner sc = new Scanner(System.in); int divisor = 0; int dividend = 0; System.out.print("나뉨수를 입력하시오 :"); dividend = sc.nextInt(); System.out.print("나눗수를 입력하시오:"); divisor = sc.nextInt(); try { System.out.println(dividend/divisor); } catch (ArithmeticException e) { System.out.println("0으로 나눌 수 ..