Created
June 2, 2022 05:15
-
-
Save valbaca/bba15599e36eda70c2c8ae34281c21d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.valbaca; | |
import java.util.ArrayList; | |
import java.util.Date; | |
import java.util.List; | |
public class Gens { | |
public static void main(String[] args) { | |
List<Class> classes = new ArrayList<>(); | |
classes.add(String.class); | |
classes.add(Date.class); | |
List things = new ArrayList(); | |
things.add("foo"); | |
things.add(new Date()); | |
for (Class clazz : classes) { | |
List list = new ArrayList(); | |
for (Object something : things) { | |
if (clazz.isInstance(something)) list.add(something); | |
} | |
System.out.print(clazz.getSimpleName()); | |
System.out.print(list); | |
System.out.println(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment