본문 바로가기
728x90
반응형

전체 글565

[Java] 27 ~ 28. Test5 (Consumer 인터페이스를 이용하여 학생 정보를 출력하는 printString 함수와 main 함수를 완성하기) package chap10; /* * Consumer 인터페이스를 이용하여 학생 정보를 출력하는 * printString 함수와 main 함수를 완성하기 [결과] name=홍길동, eng=90, math=80, major=경영 name=김삿갓, eng=95, math=70, major=컴공 name=이몽룡, eng=85, math=75, major=통계 */ import java.util.function.Consumer; class Student { private String name; private int eng; private int math; private String major; public Student(String name,int eng,int math,String major){ this.na.. 2022. 3. 24.
[Java] 27 ~ 28. Test4 (LambdaInterface4를 이용하여 배열 중 최소/최대값을 구해주는 함수 calc 함수 람다식을 구현하시요) package chap10; /* * LambdaInterface4를 이용하여 배열 중 최소/최대값을 구해주는 함수 calc 함수 * 람다식을 구현하시요 */ public class Test0318_4 { public static void main(String[] args) { int[] arr = {1,2,3,4,5,6,7,8,9,10}; System.out.println("배열 중 최대값:"+calc(arr,f)); System.out.println("배열 중 최소값:"+calc(arr,f)); } static int calc(int[] arr,LambdaInterface4 f) { } } 2022. 3. 24.
[Java] 27 ~ 28. Test3 (LambdaInterface3 인터페이스를 이용하여 람다방식으로 입력된 숫자까지의 합을 출력하는 프로그램 구현하기) package chap10; /* * LambdaInterface3 인터페이스를 이용하여 람다방식으로 * 입력된 숫자까지의 합을 출력하는 프로그램 구현하기 */ public class Test0318_3 { public static void main(String[] args) { f.method(4); f.method(10); f.method(100); } } 2022. 3. 24.
[Java] 27 ~ 28. Test2 (main 메서드에서 method1() 메서드를 호출하고, method1 메서드에서 value 값을 출력하여 다음의 결과가 나오도록 프로그램 수정하기) package chap10; /* main 메서드에서 method1() 메서드를 호출하고, method1 메서드에서 value 값을 출력하여 다음의 결과가 나오도록 프로그램 수정하기 [결과] 지역 변수 value=30 내부클래스 객체의 멤버 value=20 외부클래스 객체의 멤버 vlaue=10 */ class Outer11 { int value = 10; class Inner { int value = 20; void method1() { int value = 30; } } } public class Test0318_2 { public static void main(String[] args) { } } 2022. 3. 24.
728x90
반응형