Update Sample.java

added a new function to the sample Java file.