figure out


1) to understand or solve something


2) to calculate an amount



You can figure it out. 

너 해결할 수 있어.


I just can't figure out why.    (Rihanna - We ride 노래 中)

난 도저히 이유를 알 수가 없어.

'me myself and i > english' 카테고리의 다른 글

담당 부서를 가르쳐 주세요  (0) 2018.03.28
영어회화 100일의 기적 - 2일차  (2) 2018.03.27
영어회화 100일의 기적 - 1일차  (0) 2018.03.25
다 잘 될거야  (0) 2018.01.09
Just give up. 포기해!  (0) 2018.01.08

이런식으로 리턴값을 선언할 수도 있다.





package study;


public class CalculatorExample {

public static void main(String[] args) {


double result1 = 10 * 10 * Calculator2.pi;

int result2 = Calculator2.plus(10, 5);

int result3 = Calculator2.minus(10, 5);

System.out.println("result1 : " + result1);

System.out.println("result2 : " + result2);

System.out.println("result3 : " + result3);

}

}



class Calculator2 {

static double pi = 3.14159; 

static int plus(int x, int y)

{

return x + y;

}

static int minus(int x, int y)

{

return x - y;

}

}




(콘솔)

result1 : 314.159

result2 : 15

result3 : 5



return은 함수가 결과물을 반환한다는 뜻이고, 반환 하는 순간 함수는 종료된다. (지금 동작하는 구문을 빠져나가는 것)

return값이 없으면 void 메소드를 사용한다.

매개변수가 있으면 호출시에도 매개변수 값 입력해야 한다.





package study;


public class CalculatorExample {

public static void main(String[] args) {


Calculator myCalc = new Calculator();

myCalc.powerOn();

int result1 = myCalc.plus(5, 6);

System.out.println("result1 : " + result1);

byte x = 10;

byte y = 4;

double result2 = myCalc.divide(x, y);

System.out.println("result2 : " + result2);

myCalc.powerOff();

}

}



class Calculator {

//메소드

void powerOn() //리턴값x

{

System.out.println("전원을 켭니다.");

}

int plus(int x, int y)

{

int result = x + y;

return result; //리턴값o

}

 

double divide(int x, int y)

{

double result = (double)x / (double)y;

return result;

}

void powerOff()

{

System.out.println("전원을 끕니다.");

}

}






(콘솔)

전원을 켭니다.

result1 : 11

result2 : 2.5

전원을 끕니다.



+ Recent posts