Problem statement: In given java code, can you please let me know, what will be the output.
[com.practice.core.A@15db9742, com.practice.core.B@6d06d69c, com.practice.core.C@7852e922, com.practice.core.A@4e25154f]
Size: 4
Note: fully_qualified_class_name@hashcode_value
- import java.util.ArrayList;
- class A {}
- class B {}
- class C {}
- public class Test {
- public static void main(String[] args) {
- ArrayList list = new ArrayList();
- list.add(new A());
- list.add(new B());
- list.add(new C());
- list.add(new A());
- System.out.println(list);
- System.out.println("Size: " + list.size());
- }
- }
[com.practice.core.A@15db9742, com.practice.core.B@6d06d69c, com.practice.core.C@7852e922, com.practice.core.A@4e25154f]
Size: 4
Note: fully_qualified_class_name@hashcode_value
No comments:
Post a Comment