Skip to content

Instantly share code, notes, and snippets.

@lol97
Last active January 21, 2024 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lol97/76adc01928a5583fcc35e73fb94a68a0 to your computer and use it in GitHub Desktop.
Save lol97/76adc01928a5583fcc35e73fb94a68a0 to your computer and use it in GitHub Desktop.
import java.math.BigDecimal;
public class NoArgument {
interface Reference{
public BigDecimal getGravitionalEnergyValue();
}
public void doCalculateForce() {
Reference refInner= new Reference() {
public BigDecimal getGravitionalEnergyValue() {
BigDecimal grav = new BigDecimal(9.80f);
return grav;
}
};
System.out.println("show gravitional value from inner = " + refInner.getGravitionalEnergyValue());
}
public static void main(String[] args) {
Reference ref =
()-> {
BigDecimal grav = new BigDecimal(9.80f);
return grav;
};
System.out.println("show gravitional value from main = " + ref.getGravitionalEnergyValue());
NoArgument noArgument = new NoArgument();
noArgument.doCalculateForce();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment