There is a feature in Eclipse called Scrapbook page through which we can execute a snippet of the java code for ex. an expression without creating a new java class.
Steps to create a Scrapbook page in eclipse:
1. Select File->New->Other->Java->Java Run/Debug->Scrapbook page
2. Enter a name for the page.
3. Click Finish.
This will create a scrapbook page with the extension .jpage. A new editor will open for the scrapbook page. In the scrapbook page we can type an expression for ex:
int firstNum=10, secondNum=20; int sum = firstNum+secondNum; return sum;
Select the code snippet with Ctrl+A and then execute this with Run->Display. It will display the result.