fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.Map;
  4. import java.util.Map.Entry;
  5. import java.util.function.Consumer;
  6.  
  7. public class BBBB {
  8.  
  9. public void ExampleFoo() {
  10.  
  11. Consumer<Entry<Student, Integer>> action = new Consumer<Entry<Student, Integer>>() {
  12. @Override
  13. public void accept(Entry<Student, Integer> t) {
  14. Student s = t.getKey();
  15. int i = t.getValue();
  16. //
  17. // your code goes here
  18. //
  19. }
  20. };
  21.  
  22. for (Classroom kumi : Classroom.values()) {
  23. mainList.entrySet().stream()
  24. .filter(t -> t.getKey().getClassroom() == kumi)
  25. .forEach(action);
  26. }
  27. }
  28.  
  29. Map<Student, Integer> mainList;
  30.  
  31. class Student {
  32. Classroom kumi;
  33. int number;
  34. String name;
  35.  
  36. public Classroom getClassroom() {
  37. return kumi;
  38. }
  39. }
  40.  
  41. enum Classroom {
  42. Kumi_1("1組"), Kumi_2("2組"), Kumi_n("n組");
  43.  
  44. private String value;
  45.  
  46. private Classroom(String value) {
  47. this.value = value;
  48. }
  49.  
  50. public String getValue() {
  51. return value;
  52. }
  53. }
  54. }
  55.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:7: error: class BBBB is public, should be declared in a file named BBBB.java
public class BBBB {
       ^
1 error
stdout
Standard output is empty