본문 바로가기

전체 글388

자바를 자바 08(클래스 세부, call-by-value) Creating an Array of Objects class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return this.name; } } public class Lecture{ public static void main(String[] args){ Employee m[] = new Employee[3]; m[0] = new Employee("Mario"); m[1] = new Employee("Luigi"); m[2] = new Employee("Toad"); System.out.println(m[0].getName()); } } Instance Var.. 2020. 11. 16.
자바를 자바 과제01 Problem 01 A~z의 문자하나는 아스키코드 출력 그 이외는 모두 에러 메세지 출력 주요점 결국 내가 받은 문자가 어떤것인지 명확하게 정의내려야 함 또한 받은 문자열의 길이를 확인하여서 if문 조건에 넣어주어야 함 문자는 String 으로 받고 charAt(0) 을 통해 문자를 잘라서 아스키 값을 int로 저장해 두어야 함 import java.util.Scanner; public class Problem1 { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("ASCII code teller. Enter a letter: "); String val = in.nextLine(); .. 2020. 11. 16.
자바를 자바 07 Java : An Object-Oriented Language In Java, most variables and literals are objects An object is an instance of a class class Employee{ String name; public void setName(String name){ this.name = name; } public String getName(){ return this.name; } } public class Lecture{ public static void main(String[] args){ Employee m = new Employee(); // 이게 바로 object, instance } } Class Definition 한개의 .java .. 2020. 11. 16.
자바를 자바 06 1.8 Arrays Single-dimensional Array 선언방법 int [] a = new int[10]; int a[] = new int[10]; 초기 값 int,long,float : 0 boolean : false char : ASCII CODE 0 string, frame : null ex> class arNew{ public static void main(String[] args){ int[] a = new int[10]; int b[] = new int[10]l int i; for(i=0;i class arYeeChaWon { public static void main(String[] args) { int a[][] = { {10,11,12}, {20,21,22}, {30,31,32}.. 2020. 11. 16.