I'd like to quickly check the result of a static method I'm analyzing, within the IDE if possible.
public static int foo(int a, int b){
return (a & 11) ^ b;
}
For example, right-click the expression and run it, something like
> foo(11, 2)
> 9
> foo(28, 3)
> 11
I don't know the result in advance (the actual code is more complicated), so unit testing is out of the question.
How can I do this?
In Eclipse there are the so-called Java Scrapbook Pages: see Eclipse Help - Creating a Java Scrapbook Page
Since Java 9 there is the so-called JShell which can also be used without an IDE: see Oracle Help Center - Introduction to JShell
Java 9 JShell can be used from IntelliJ IDEA: Tools | JSHell Console... action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With