Advertisement
476179

IntAndFloatingPointDivision

Sep 30th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. package lessons;
  2.  
  3. public class IntAndFloatPointDiv
  4. {
  5.  
  6. public static void main(String[] args)
  7. {
  8. double n1;
  9. n1 = 5/2;
  10. System.out.println(n1);
  11. //when two numbers are integer numbers(without decimal)
  12. //you will get int result
  13.  
  14. double n2;
  15. n2 = 5.0/2;
  16. System.out.println(n2);
  17. // when using a float you will always get a floating point number
  18. //will always put it in highest datatype out of the ones used
  19.  
  20. }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement