0

I am very new to Java (and Android development). To debug, I want to mimic php var_dump method. So following some posts, I found and used that inside an activity (that is called when I launch the emulator)

HttpRequest request = execute(HttpRequest.get(URL_USERS));
            UsersWrapper response = fromJson(request, UsersWrapper.class);
            Field[] fields = response.getClass().getDeclaredFields();
            for (int i=0; i<fields.length; i++)
            {
                System.out.println(fields[i].getName() + " - " + fields[i].get(o));
            }

I am using intelliJ ide, and I have no output of the System.out How can it be ?

4

2 回答 2

2

谷歌gson是你可以在 java 中获得的最好的。您可以将对象转储到 json 中,它适用于几乎所有类型的 java 对象。

于 2018-01-01T14:15:08.380 回答
0

Java不是PHP :) 模仿var_dump是不可能的,因为对象不仅仅是Map键和值。查看对象的所有变量的正确方法是在您创建(或使用)对象的行设置断点并在调试器中检查其变量。

于 2013-11-07T18:10:44.890 回答