본문 바로가기

분류 전체보기391

자바를 자바 과제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.
자바를 자바 05(String/input,output/Control Flow) 1.5 Strings 변수를 선언하는 것에 있어서도 new를 사용하고 안하고는 큰 차이가 생김 new 를 쓴다는 것은 공간을 생성하여서 값을 대입하는 것이기 때문에 이때 변수에 저장된 것은 메모리 공간의 주소이지 메모리 공간의 값이 저장된 것이 아니다. String s1 = "Java"; String s2 = "JAVA"; if(s1=="Java") System.out.println("same"); //여기에서 물어보는 것은 같은 객체를 참조하는지 물어보는 것이다. //동적할당된 객체가 아니기 때문에 same 문구가 출력된다. if(s1.toUpperCase() == s2) System.out.println("same"); //이 것은 s1의 객체를 가지고 와서 대문자로 바꾼다음 새로운 객체를 반환 //.. 2020. 11. 16.