본문 바로가기

분류 전체보기

(51)
메서드 오버로딩(Overloading) 예시) public class Add { int add(int a, int b) { int result = a+b; return result; } double addDouble(double a, double b) { double result = a + b; return result; } double addIntDouble(int a, double b){ double result = a+b; return result; } } public class AddTest { public static void main(String[] args) { // TODO Auto-generated method stub // 2, 3 두수를 주면, 이 두수를 더한 결과를 리턴해주는 함수필요 Add a = new Add(); S..
Static 변수 예시) public class StaticVar { String name; int score; int count; } public class StaticTest { public static void main(String[] args) { // TODO Auto-generated method stub StaticVar sv1 = new StaticVar(); sv1.name = "홍길동"; sv1.score = 90; sv1.count = 1; StaticVar sv2 = new StaticVar(); sv2.name = "김나나"; sv2.score = 70; sv2.count = 2; System.out.println("지금까지 학생수는 "+sv1.count); } } ● 몇개의 class 객체를 만들..
자바 class와 객체(인스턴스) / 자바 메모리 관련 0630 ▶ 자바에서 클래스는 틀이고, 인스턴스는 메모리에 올라온 상태를 의미한다. 더 자세히 설명하면, 클래스는 객체들의 공통점을 찾아내서 하나의 틀로 만든것이다 그리고 메모리에 실제로 들어가게 되는 데이터가 객체이다. ※ 데이터베이스의 테이블과 비슷한데 테이블은 행으로 추가되며 디스크에 저장된다 그리고 테이블은 변수만 있다고 본다면 클래스에는 변수와 함수가 들어갈 수 있다. ▷ 좀 더 전문적인 표현으로, 클래스의 변수는 멤버 변수 / 클래스에 들어있는 함수는 메서드라고한다. public class StudentTest { public static void main(String[] args) { // TODO Auto-generated method stub Student s1 = new Student(); St..
자바 함수 0630 ▶ 함수를 정의하는 방법 함수 return값의 데이터타입 함수명 (파라미터 또는 로컬(local)변수) - 만약 return값이 없고 어떤 기능만 수행한다면 void를 써준다 public class FuncTest { public static void main(String[] args) { // TODO Auto-generated method stub int a = 10, b = 20; FuncTest ft = new FuncTest(); int c = ft.add(a,b); System.out.println(c); String apple = ft.getGrade(27); System.out.println(apple); ft.printHello(3); } // 두 정수를 더해주는 함수를 만들고 싶다. i..
자바 배열(Array) 0630 ● 배열은, 데이터 여러개 저장하는 것. ● 자바의 가장 기본적인 데이터 스트럭쳐이다. ● 근데 구려서 실무에서 잘 안쓴다 고 한다 그래서 실무에서는 ArrayList와 HashMap을 사용한다. public class ArrayTest { public static void main(String[] args) { // TODO Auto-generated method stub // 학생들 50명의 수학점수를 처리하려 한다. int[] scoreArr = new int[50]; scoreArr[0] = 70; scoreArr[1] = 80; scoreArr[2] = 90; // System.out.println(scoreArr[1]); // 학생 20명의 수학점수를 관리하려 합니다. // 모든 학생의 점수를..
자바 switch, 반복문 0630 public class Switch { public static void main(String[] args) { // TODO Auto-generated method stub int a = 1; // a가 1이면 헬로우, 2이면 바이, 3이면 좋아요, 4면 나이스 // 위에 해당 안되면 끝~ 이라고 출력 // switch 조건문 switch(a) { case 1 : System.out.println("헬로우"); break; case 2 : System.out.println("바이"); break; case 3: System.out.println("좋아요"); break; case 4: System.out.println("나이스"); break; default : System.out.println("끝 ..
자바 연산자 활용, 조건문 0630 public class VarTest { public static void main(String[] args) { // TODO Auto-generated method stub int a = 12; int b = 13; float c = 0f; c = (a + b) / 2; System.out.println(c); c = (a + b)/2.0f; System.out.println(c); c =((float)a + (float)b)/2; System.out.println(c); c = (float)(a+b) / 2; System.out.println(c); int g = 0; a = 20; b = 10; g = a+b; g = a-b; g = a*b; g = a / b; g = a % b; } } ● 정수..
자바 Project, class 생성 및 문법 기초 0629 ● 자바의 핵심은 class이다. ● class는 변수와 함수의 묶음이다. ● package는 자바에서 폴더같은 개념이다. ○ 자바 프로젝트를 생성해보자! ○ main 함수 부분에 내용을 넣어보자! - CPU가 처음 동작하는 부분이 바로, main 함수! public class Hello { public static void main(String[] args) { System.out.println("안녕하세요"); // TODO Auto-generated method stub int price = 3000; price = 4000; int age; age = 27; int result; result = price + age; double rate = 15.4; float data = 17.7f; Stri..
Eclipse 설치하기 ● Eclipse란? : eclipse 자바뿐만 아니라 다양한 언어를 지원하는 통합개발환경이다 ● 설치과정 1. 사이트로 들어간다. https://www.eclipse.org/downloads/ Eclipse Downloads | The Eclipse Foundation The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 415 open source projects, including runtimes, tools and frameworks. www.eclipse.org 2. Download 버튼 눌러서 이클립스 다운로드한다 3. 이클립스 설치한다
자동 배포 하기 1. vsc의 serverless.yml 수정 2. 깃허브 해당 레파지토리의 설정 클릭 서버리스 엑세스 키 추가/ AWS 엑세스 키 ID와 AWS 시크릿 엑세스 키 추가 3. 해당 레파지토리의 Actions클릭 main.yml에 추가 name: 원하는 이름 정해주기 on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest env: SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} steps: -..