fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8.  
  9. class B {
  10. int x;
  11. int y;
  12. }
  13.  
  14. class A {
  15.  
  16. List<B> Blist;
  17.  
  18. void setBlist(List<B> bList) {
  19. Blist = bList;
  20. }
  21.  
  22. List<B> getBlist() {
  23. return Blist;
  24. }
  25.  
  26. }
  27.  
  28.  
  29. class Ideone
  30. {
  31. public static void main (String[] args) throws java.lang.Exception
  32. {
  33. // your code goes here
  34. A a = new A();
  35. B b1= new B();
  36. b1.x=10; b1.y=10;
  37. B b2= new B();
  38. b2.x=10; b2.y=10;
  39. List<B> bList = new LinkedList<>();
  40. bList.add(b1);
  41. bList.add(b2);
  42. a.setBlist(bList);
  43. List<B> fetchAList = a.getBlist();
  44. fetchAlist.add(b2);
  45. System.out.println(fetchAList.size());
  46. System.out.println(a.getBlist().size());
  47. }
  48. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:44: error: cannot find symbol
		fetchAlist.add(b2);
		^
  symbol:   variable fetchAlist
  location: class Ideone
1 error
stdout
Standard output is empty