开发者

How do I view different representations of integers in the Eclipse watch window?

I would like to view binary (or hex) representations of integers in my watch w开发者_JS百科indow in Eclipse when debugging. How do I do this?


You can do this from Window->Preferences.

For primitives, browse to Java->Debug->Primitive Display Options

Here there is a checkbox for 'Display Hexadecimal values'. Check this, and you will see both decimal & hexadecimal representations for primitives in the 'value' column under Variables view when debugging.

For objects (Integer, Long, etc), browse to Java->Debug->Detail Formatters

For each type you care about, create a detail formatter that formats the value how you like. For java.lang.Integer, you could use the detail formatter: Integer.toHexString(this)

Make sure your detail formatter is enabled, and you should see the hexadecimal representation in the 'details' area when you select a variable from the Variables view.


Your best option is probably to open the Expressions view (Window -> Show View -> Expressions), right click, choose "Add Watch Expression" and then enter Integer.toBinaryString(yourInt) or Integer.toHexString(yourInt), and click ok.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜