프로그래밍/JAVA
-
[JAVA/Eclipse] 제네릭과 컬렉션프로그래밍/JAVA 2023. 11. 28. 11:18
제네릭이란? 다양한 종류의 데이터를 처리할 수 있는 클래스와 메소드를 작성하는 기법 기존에는 일반적인 객체를 처리하기위해 Object 참조 변수를 사용 기존 방식 public class Box { private Object data; public void set(Object data) { this.data = data; } public Object get() { return data; } } Box b = new Box(); b.set("Hello World!"); // ① 문자열 객체를 저장 String s = (String)b.get();// ② Object 타입을 String 타입으로 형변환 b.set(new Integer(10)); // ③ 정수 객체를 저장 Integer i = (Integer)..
-
[JAVA] Simpletron프로그래밍/JAVA 2023. 11. 8. 16:27
2023-11-08 완벽 이해 완료 package SimpletronProject; import java.util.Scanner; public class Simpletron { public static void main(String[] args) { System.out.println("*** Welcome to Simpletron! ***"); System.out.println("*** Please enter your program one instruction ***"); System.out.println("*** (or data word) at a time. I will type the location number ***"); System.out.println("*** and a question mar..