본문 바로가기
728x90
반응형

study/Java305

[Java] 27 ~ 28. Test1 풀이 (Outer10클래스의 내부 클래스 Inner1, inner2 의 멤버변수 iv의 값 출력) package chap10; //Outer10클래스의 내부 클래스 Inner1, inner2 의 멤버변수 iv의 값 출력 class Outer10 { class Inner1 { int iv = 100; } static class Inner2 { int iv = 200; } } public class Test0318_1 { public static void main(String[] args) { System.out.println(new Outer10().new Inner1().iv); System.out.println(new Outer10.Inner2().iv); } } 2022. 3. 24.
[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.
728x90
반응형