No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Opérateurs relationnels

Description du code

Code source ou contenu du fichier

  1. public class OperateursRelationnels {
  2. public static void main(String[] args) {
  3.  
  4. //a few numbers
  5. int i = 37;
  6. int j = 42;
  7. int k = 42;
  8. System.out.println("Variable values...");
  9. System.out.println(" i = " + i);
  10. System.out.println(" j = " + j);
  11. System.out.println(" k = " + k);
  12.  
  13. //greater than
  14. System.out.println("Greater than...");
  15. System.out.println(" i > j = " + (i > j)); //false
  16. System.out.println(" j > i = " + (j > i)); //true
  17. System.out.println(" k > j = " + (k > j)); //false, they are equal
  18.  
  19. //greater than or equal to
  20. System.out.println("Greater than or equal to...");
  21. System.out.println(" i >= j = " + (i >= j)); //false
  22. System.out.println(" j >= i = " + (j >= i)); //true
  23. System.out.println(" k >= j = " + (k >= j)); //true
  24.  
  25. //less than
  26. System.out.println("Less than...");
  27. System.out.println(" i < j = " + (i < j)); //true
  28. System.out.println(" j < i = " + (j < i)); //false
  29. System.out.println(" k < j = " + (k < j)); //false
  30.  
  31. //less than or equal to
  32. System.out.println("Less than or equal to...");
  33. System.out.println(" i <= j = " + (i <= j)); //true
  34. System.out.println(" j <= i = " + (j <= i)); //false
  35. System.out.println(" k <= j = " + (k <= j)); //true
  36.  
  37. //equal to
  38. System.out.println("Equal to...");
  39. System.out.println(" i == j = " + (i == j)); //false
  40. System.out.println(" k == j = " + (k == j)); //true
  41.  
  42. //not equal to
  43. System.out.println("Not equal to...");
  44. System.out.println(" i != j = " + (i != j)); //true
  45. System.out.println(" k != j = " + (k != j)); //false
  46.  
  47. }
  48. }

Autres extraits de codes en Java

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 05/10/2009, last modified the 28/10/2018
Source of the printed document:https://www.gaudry.be/en/sniplet-rf-java/OperateursRelationnels.java.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.