프로그래밍

[자바 오류] java.io.NotSerializableException 본문

오류

[자바 오류] java.io.NotSerializableException

시케 2023. 5. 22. 22:11
728x90
반응형

오류코드

class Product {
	static Scanner sc = new Scanner(System.in);

	private int num; // 상품 PK
	private String name;// 상품명
	private int price; // 상품 가격
	private int cnt; // 상품 재고
	....

오류 메세지

 

java.io.NotSerializableException: class03.Product

 

해결

해당 에러가 발생 되는 원인은 해당 class가 직렬화 되어 있지 않기 때문이므로

직렬화한다

class Product implements Serializable {
	static Scanner sc = new Scanner(System.in);

	private int num; // 상품 PK
	private String name;// 상품명
	private int price; // 상품 가격
	private int cnt; // 상품 재고
	....

 

 

 

 

728x90
반응형
Comments