Is there something like python's interactive REPL mode, but for Java?

前端 未结 28 1251
一个人的身影
一个人的身影 2020-11-29 16:38

Is there something like python\'s interactive REPL mode, but for Java? So that I can, for example, type InetAddress.getAllByName( localHostName ) in a window, a

28条回答
  •  心在旅途
    2020-11-29 17:07

    The groovy console allows you to do that. It actually was meant to try and test groovy code, but since groovy is a superset of Java, it allows plain Java stuff as well.

    I just entered this into the console:

    InetAddress.getAllByName('localhost')
    

    and hit CTRL-R, then it returned:

    groovy> InetAddress.getAllByName('localhost')
    
    Result: [localhost/127.0.0.1]
    

提交回复
热议问题