Guest User

Untitled

a guest
Aug 10th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. BeanUtils - 'describe' method returning Incorrect array value
  2. public class Demo {
  3.  
  4. private ArrayList<String> myList = new ArrayList<String>();
  5.  
  6. public Demo() {
  7. myList.add("first_value");
  8. myList.add("second_value");
  9. }
  10.  
  11. public ArrayList<String> getMyList() {
  12. return myList;
  13. }
  14.  
  15. public void setMyList(ArrayList<String> myList) {
  16. this.myList = myList;
  17. }
  18.  
  19. public static void main(String[] args) {
  20. Demo myBean = new Demo();
  21. try {
  22. Map describe = BeanUtils.describe(myBean);
  23. Iterator it = describe.entrySet().iterator();
  24. while (it.hasNext()) {
  25. Map.Entry pairs = (Map.Entry) it.next();
  26. System.out.println(String.format("key=%s,value=%s", (String) pairs.getKey(), (String) pairs.getValue()));
  27.  
  28. }
  29. } catch (Exception e) {
  30. e.printStackTrace();
  31. }
  32. }
  33. }
Add Comment
Please, Sign In to add comment