JAVA
-
자바문법JAVA 2020. 7. 14. 13:39
private Context cntxt; public Inipay(Context c) { this.cntxt = c ; } //클래스내에서만 사용하는 변수 //생성자 함수(첫글자는 대문자) (타입 변수) { 현재 클래스의cntxt는 파람값 넣기 } public boolean doPay(WebView view , String url ) { return false; } boolean 생성자뒤에 있는경우 리턴값이 boolean으로 리턴된다 void 리턴할 필요가 없는경우 void를 사용한다
-
@override, @overloadJAVA 2020. 7. 14. 13:37
@override 상위객체에 상속된 함수를 재정의 한다는 뜻 @overload 상위객체에 상속된 함수에 param값을 적용하여 상속된함수 사용한다는 뜻 ex)php 풀이 class Foo { public void foo() { print(1); } private void aoo() { } protected void boo() { } } class Aaa extends Foo { @Override public void foo() { //super.foo(); print(2); } @Overload public void foo(string a) { } }
-
배열생성JAVA 2020. 5. 6. 18:47
int[] a = new int[3]; int[] b; b = new int[3]; //선언된 변수가 배열변수가 아니다 //int c; //c = new int[3]; // error //배열만들기 ArrayList tmpAry = new ArrayList(); //배열입력 tmpAry.add("aaa"); tmpAry.add("bbb"); //출력 System.out.println(tmpAry); //배열출력 System.out.println(tmpAry.get(1)); //원하는 위치의 배열값출력 System.out.println(tmpAry.indexOf("bb")); //해당값을 가지고잇는 index출력 tmpAry.forEach(idx -> System.out.println(idx)); // 반..
-
메소드JAVA 2020. 5. 6. 18:46
package test01; public class Test { static int a = 0; int c = 0; Test() { this.a++; this.c++; } public int getNum(int num) { return num; } public static class test2 { int p = 0; String str = "aaaaa"; int tmpNum; public void setNum(int num) { this.tmpNum = num; } } public void say_nick(String nick) { //equals 같은경우 if("fool".equals(nick)) { return; } System.out.println("별명은 "+ nick + " 입니다."); } p..
-
상속 extendsJAVA 2020. 5. 6. 18:45
package test01; public class Test03 extends Test { public void setName44(String name) { System.out.println(name); } public static void main(String[] args) { Test03 test = new Test03(); Test test2 = new Test03(); //Test03 test3 = new Test(); //error 자식클래스변수는 부모클래스를 불러올수 없다 //부모상속 클래스에 자식 클래스를 인스턴스할수잇다 } }
-
오버로딩JAVA 2020. 4. 22. 10:33
package test01; class ThisA { int num; public ThisA() { } public ThisA(ThisA a) { System.out.println("객체 오버로딩"); num = a.num; } public ThisA(ThisA... a) { System.out.println("객체 여러개 오버로딩"); for(ThisA b : a) { System.out.println(b.num); } } public ThisA(int a) { System.out.println("int 오버로딩"); num = a; } public void setNum (int input_num) { num = input_num; } public void display() { System.out.pr..