본문 바로가기
BackEnd/Backend 공부 정리

Java-15

by Brilliant_Graphite 2024. 8. 27.

ERP ( 전사적 자원 관리 )

국내 - 더존

 

익명 enum 클래스 -> 람다로 많이 사용

 

DI 

프레임워크가 제어함

 

인터페이스

 

public interface 인터페이스명 {
}

 

public  class클래스명 implements 인터페이스명 {
}

 

제너릭

List<String>

지정된 타입만 받을 수 있게 표현

 

스트림 객체

 

List - ArrayList ( 배열의 단점을 극복, 동적인 크기, 순차적, 중복된 데이터 가능)

 

Set 

Map

- HashMap ( 2개의 파라미터만 가능, 중복 허용 X )

 

Eclipse

Ctrl + H : 파일 찾기 (문자열 패턴을 보고)

 

package InterfaceEx;

public interface IFunction {

	void callSenderReceive();

	void canLte();

	void tvRemoteController();

}

 

package InterfaceEx;

public abstract class Phone {
	public String owner;

	public Phone(String owner) {
		this.owner = owner;
	}

	public void turnOn() {
		System.out.println("폰 전원을 켭니다.");
	}

	public void turnOff() {
		System.out.println("폰 전원을 끕니다.");
	}
}

 

package InterfaceEx;

public class PhoneMain {

	public static void main(String[] args) {
		//APhoneImpl aPhone = new APhoneImpl();
		//BPhoneImpl bPhone = new BPhoneImpl();
		//CPhoneImpl cPhone = new CPhoneImpl();
		
		IFunction aPhone = new APhoneImpl();
		IFunction bPhone = new BPhoneImpl();
		IFunction cPhone = new CPhoneImpl();
		
		IFunction[] iFunctions = {aPhone, bPhone, cPhone};
		
		for (int i = 0; i < iFunctions.length; i++) {
			iFunctions[i].callSenderReceive();
			iFunctions[i].canLte();
			iFunctions[i].tvRemoteController();
			System.out.println("==================");
		}

	}

}

 

package CollectionEx;

import java.util.ArrayList;

public class ArrayListExampleEx {

	public static void main(String[] args) {
		//ArrayList arry = new ArrayList();
		
		//arry.add("장길산");
		//arry.add("홍길동");
		
		//String hong = (String)arry.get(1);
		
		
		ArrayList<String> arry = new ArrayList<>();
		arry.add("장길산");
		arry.add("홍길동");
		
		String hong = arry.get(1);
		arry.forEach(i -> System.out.println(i));
		
		for(int i = 0; i < arry.size(); i++) {
			System.out.println(arry.get(i));
		}
		
		for(String str : arry) {
			System.out.println(str);
		}

	}

}

 

package CollectionEx;

public class BookDTO {
	private String title;
	private String auth;
	private String pub;
	private int price;
	
	public BookDTO(String title, String auth, String pub, int price) {
		super();
		this.title = title;
		this.auth = auth;
		this.pub = pub;
		this.price = price;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getAuth() {
		return auth;
	}

	public void setAuth(String auth) {
		this.auth = auth;
	}

	public String getPub() {
		return pub;
	}

	public void setPub(String pub) {
		this.pub = pub;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	@Override
	public String toString() {
		return "BookDTO [title=" + title + ", auth=" + auth + ", pub=" + pub + ", price=" + price + "]";
	}
	
	
}

 

package CollectionEx;
import java.util.ArrayList;
import java.util.Iterator;

public class ArrayListExampleEx2 {

	
	
	public static void main(String[] args) {
		
		ArrayList<BookDTO> bookList = new ArrayList<>();
		
		for (int i = 1; i < 4; i++) {
			BookDTO bookDto = new BookDTO("title" + i, "auth" + i, "pub" + i, 20000 * i);
			bookList.add(bookDto);
			
		}
		
		for(int i = 0; i <bookList.size(); i++) {
			System.out.println(bookList.get(i).getTitle());
			System.out.println(bookList.get(i).getAuth());
			System.out.println(bookList.get(i).getPub());
			System.out.println(bookList.get(i).getPrice());
			System.out.println("====================");
		}
		
		for(BookDTO bookDTO : bookList) {
			System.out.println(bookDTO.getTitle());
			System.out.println(bookDTO.getAuth());
			System.out.println(bookDTO.getPub());
			System.out.println(bookDTO.getPrice());
			System.out.println("====================");
		}

	}

}

'BackEnd > Backend 공부 정리' 카테고리의 다른 글

sqldeveloper-16  (0) 2024.08.28
Java-16  (0) 2024.08.28
sqldeveloper-14  (0) 2024.08.26
Java-14  (0) 2024.08.26
sqldeveloper-13  (0) 2024.08.23