Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create a class with method via jshell and invoke the method
jshell> public class Sample {
...> public int add(int a, int b) {
...> return a+b;
...> }
...> }
| created class Sample
jshell> Sample s = new Sample();
s ==> Sample@49993335
jshell> s.add(10,9);
$4 ==> 19
jshell>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment