생성자
-
Java Class - 생성자Java 2018. 1. 16. 13:52
Notebook bn = new Notebook(); // 오버로드는 같은 이름으로 여러개의 메서드나 생성자를 만들게 해 준다.// 객체 생성시 다양한 방법을 재공해 줄 수 있다. // String model, int price, String color Notebook bn2 = new Notebook("자동차", 2500, "red"); System.out.println(bn2.model); System.out.println(bn2.price); System.out.println(bn2.color); // String model, String color Notebook bn3 = new Notebook("자동차", "red"); System.out.println(bn3.model); System.out..
-
Java - ClassJava 2018. 1. 16. 12:34
public class Main { public static void main(String[] args) { // Student Class를 복사해서 std라는 변수에 담는다. Student std = new Student(); Student std2 = new Student(); System.out.println(std); System.out.println(std2); } } // std과 std2 클래스는 다르다 public static void main(String[] args) { String a =""; String b = ""; Robot bot = new Robot(a, b); System.out.println(bot.name); System.out.println(bot.goal); } pu..