476179

NameConstWithFinal

Oct 3rd, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. package lessons;
  2.  
  3. public class NameConstWithFinal
  4. {
  5.  
  6. public static void main(String[] args)
  7. {
  8. double amt = 0, bal = 0;
  9. amt = bal * 0.069;
  10.  
  11. final double INTEREST_RATE = 0.069;
  12. //constant variables are in all caps, final makes it a constant,
  13. //so you cannot change value later on
  14.  
  15. amt = bal * INTEREST_RATE;
  16.  
  17.  
  18. }
  19.  
  20. }
Add Comment
Please, Sign In to add comment