[英]Get the list of invoking method name's from Hashmap put()
Can you help me to get the list method name's from the HashMap put method.你能帮我从 HashMap put 方法中获取列表方法名称吗?
Book book= new Book();
book.setTitle("The Little Prince");
book.setAuthor("Antoine de Saint-Exupery");
book.setPrize(9.99);
book.setPublisher("Delux Pop-up book");
HashMap<String,String> map= new HashMap<String,String>();
map.put("title",book.getTitle());
map.put("author",book.getAuthor());
map.put("prize",String.valueOf(book.getPrize()));
map.put("publisher",validatePuplisher(book.getPublisher()));
Excepted result is: book.getTitle(),book.getAuthor(),String.valueOf(book.getPrize()),validatePuplisher(book.getPublisher())
ie just method name's not value from the method.例外结果是: book.getTitle(),book.getAuthor(),String.valueOf(book.getPrize()),validatePuplisher(book.getPublisher())
即只是方法名称不是方法中的值。
If you want to get the method names used, then enclose them in double quotes to be treated as actual string.如果要获取使用的方法名称,请将它们括在双引号中以被视为实际字符串。
HashMap<String,String> map= new HashMap<String,String>();
map.put("title","book.getTitle()");
map.put("author","book.getAuthor()");
map.put("prize","book.getPrize()");
map.put("publisher","book.getPublisher()");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.