0% found this document useful (0 votes)
41 views

Anonymous Interface

This document shows how to use anonymous classes and method references in Java. It defines an interface with a getCipher method that takes an ArrayList, and two classes - one that uses an anonymous class to implement the interface on an object, calling its getCipher method; and another that uses a method reference to do the same.

Uploaded by

Debarshi Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Anonymous Interface

This document shows how to use anonymous classes and method references in Java. It defines an interface with a getCipher method that takes an ArrayList, and two classes - one that uses an anonymous class to implement the interface on an object, calling its getCipher method; and another that uses a method reference to do the same.

Uploaded by

Debarshi Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.io.

*;

import java.util.*;

interface AnonymousInterface

void getCipher(ArrayList<String> list);

class Cipher_Anonymous

void anonymousClass(ArrayList<String> list)

//Enter your Code here

AnonymousInterface obj = new AnonymousInterface(){

@Override

public void getCipher(ArrayList<String> list) {

for(String x:list){

System.out.print(x);

};

obj.getCipher(list);

class Cipher_MethodRef

void methodReference(ArrayList<String> list)

You might also like