728x90
public class main {
public static void main(String[] args) {
String a = "hello";
String b = "world";
System.out.println(a+b);
출력 : helloworld
}
}
- 메소드 만드는 이유 :
public class MethodExample {
public static void main(String[] args) {
- 클래스 생성
MethodExample methodExample = new MethodExample();
- 메소드 사용
//실행형(String 타입 2개 넘겨줌)
methodExample.StrCombine("hello","world");
// 리턴형
System.out.println(methodExample.StrTest("hello","world"));
- 메소드 만들기 (실행형 메소드)
public void StrCombine (String a, String b){
String result = a + b;
System.out.println(result);
- 메소드 만들기 (리턴형 메소드)
public String StrTest (String c, String d){
String result = c + d;
return result;
}
}
● ● void :" |
728x90
'ON > JAVA' 카테고리의 다른 글
18일 _ Map계열 /입출력 /네트워크 (0) | 2023.05.13 |
---|---|
17일 컬렉션 _ Set계열 (1) | 2023.05.11 |
16일_ 컬랙션 List계열 및 향상된 for문 (0) | 2023.05.10 |
15일차 _ 인터페이스 및 예외처리 (4) | 2023.05.09 |
14일차_객체지향 복습 및 다형성/바인딩 (0) | 2023.05.04 |