전체 글 236

JAVA 소켓프로그래밍 Network UDP

소켓프로그래밍 Network UDP 소켓프로그래밍 : 채팅 통신방식 UDP : 비연결형 ; 무전기, 개인 쪽지, 문자메세지 TCP : 연결형 ; 핸드폰, 1:1채팅 * TCP : Socket, ServerSocket 상대방과 1:1로 연결이 유지되는 객체 // Sender class import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.net.SocketException; public class UDPSender { public static void main..

Backend/JAVA 2023.03.03

JAVA 코딩 API (Application Programming Interface) - String, Object

api.io.object import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; public class Test01 { public static void main(String[] args) { int[] data = new int[] {4,1,9,15,11,6,2}; boolean[] flag = new boolean[] {true,true,false}; String day = "WED"; //객체 입출력 ObjectOutputStream oos = null; try { oos = new ObjectOutputStream(new FileOutputStream("arrays.txt")); /..

Backend/JAVA 2023.03.03

JAVA 코딩 API (Application Programming Interface) - charstream, singlebyte

api. io.charstream import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; public class Test01 { public static void main (String[] args) { BufferedWriter bw = null; try { bw = new BufferedWriter(new FileWriter("output.log")); bw.write("이게 마지막이다"); bw.newLine(); // 다음줄로 이동 bw.write("배고프다"); bw.newLine(); bw.write("뭐가 문제야 대체"); } catch (IOException e) { e.printStackTr..

Backend/JAVA 2023.03.03

JAVA 코딩 API (Application Programming Interface) - Math, System, Date, Scanner

api.lang.Math : 수학 계산 클래스 public class Test01 { public static void main (String[] args) { double a = 1.5; System.out.println(Math.floor(a)); // 버림 System.out.println(Math.round(a)); // 반올림 System.out.println(Math.ceil(a)); // 올림 int b = 3; int c = 4; System.out.println(Math.pow(b, 3)); // 제곱근 구하기 System.out.println(Math.pow(c, 2)); // 제곱근 구하기 double d = Math.pow(b, 2) + Math.pow(c, 2); double e ..

Backend/JAVA 2023.03.03

JAVA 코딩 API (Application Programming Interface) - File

API - File java.io.File : 파일과 폴더를 구별하지 않고 함게 관리하는 클래스 import java.io.File; public class Test01 { public static void main (String[] args) { File f = new File("sample.txt"); System.out.println(f.exists()); // 대상 파일이 존재하는가? System.out.println(f.isFile()); // 대상이 파일인가? System.out.println(f.isDirectory()); // 대상이 폴더인가 // 파일 정보 System.out.println(f); System.out.println(f.getName()); // 파일명 System.out...

Backend/JAVA 2023.03.02

JAVA 코딩 API (Application Programming Interface) - String : FileOutputStream, OutputStream, FileWriter, append

API - String import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; public class Test01 { public static void main (String[] args) { // 문자열 저장 File target = new File("files", "string1.txt"); OutputStream out = null; String text = "어둠만이 나의 전부였던 동안\r\n" + "숨이 벅차도록 달려왔잖아\r\n" + "Never say “time's up”\r\n" +..

Backend/JAVA 2023.03.02

JAVA 객체지향 프로그래밍 OOP, Class 상속 - 부모클래스, 자식클래스

JAVA 코딩 객체지향프로그래밍 OOP, 클래스 Class, 함수, 메소드 https://developernew.tistory.com/21 JAVA 코딩 객체지향프로그래밍 OOP, 클래스 Class, 함수, 메소드 객체 지향 프로그래밍(OOP: Object Oriented Programming) 객체 중심의 프로그래밍 방식 객체끼리의 상호 작용을 통하여 프로그램을 작성하는 방식 부품화 캡슐화 == 클래스 속성과 기능을 하나의 캡슐처 developernew.tistory.com JAVA 코딩 객체지향프로그래밍 OOP, 클래스 Class, static https://developernew.tistory.com/22 JAVA 코딩 객체지향프로그래밍 OOP, 클래스 Class, static 자바 클래스 기본개념..

Backend/JAVA 2023.02.27

JAVA 코딩 API (Application Programming Interface) - Collections Framework

Collections Framework : 무한의 데이터를 저장할 수 있는 공간 최소한의 자원으로 최대한의 효율을 낼 수 있도록 만든 프로그램의 기본 틀 ; 반 강제성을 가지고 있는 프로그램의 기본 틀 -> 결국 클래스들의 모음 Framework 최소한의 자원으로 최대한의 효율을 낼 수 있도록 만든 프로그램의 기본 틀 Collection을 상속받은 애들 : 요소 안에 데이터를 저장하는 형태 1. set : 데이터 중복 불가, 데이터 간 순서 없음 전체의 데이터를 가져오거나 넣을 때 주로 이용된다 2. List : 데이터 중복 가능, 데이터간의 순서가 유지된다 확장형 배열 인덱스값을 사용하여 데이터를 중간에 가져오거나 할 수 있다 주로 목록화된 데이터의 검색과 수정이 많이 이루어져야 하는 경우 사용된다 M..

Backend/JAVA 2023.02.23