{"id":2738,"date":"2017-06-26T17:44:05","date_gmt":"2017-06-26T17:44:05","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=2738"},"modified":"2021-03-21T06:24:14","modified_gmt":"2021-03-21T06:24:14","slug":"relational-operator-less-than-in-java","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/relational-operator-less-than-in-java\/","title":{"rendered":"Relational operator less than in Java"},"content":{"rendered":"<h3>Introduction<\/h3>\n<p>Relational operator <strong>Less Than (&lt;)<\/strong> and the operator <strong>Less Than Equal to (&lt;=)<\/strong> compares two variables for the relation less than or less than equal to.<\/p>\n<p>&lt; Relational Operator<\/p>\n<p>a &lt; b evaluates to <strong>true<\/strong> if a is <strong>less than<\/strong> b else <strong>false<\/strong><\/p>\n<p>Similarly,<\/p>\n<p>a &lt;= b evaluates to <strong>true<\/strong> if a is <strong>less than equal<\/strong> to b else <strong>false<\/strong><\/p>\n<h3>Code Listing<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/\/LessThanOperatorDemo.java\r\n\/\/www.TestingDocs.com\r\n\r\npublic class LessThanOperatorDemo {\r\n\r\n  public static void main(String[] args) {\r\n\r\n    int a = 10;\r\n    int b = 20;\r\n\r\n    if(a&lt;b)\r\n    {\r\n      System.out.println(\"a is less than b\");\r\n    }\r\n    else {\r\n      System.out.println(\"a is not less than b\");\r\n    }\r\n    System.out.println(\"The expression a &lt; b evaluates to = \" + (a&lt;b));\r\n  }\r\n}<\/pre>\n<h3>Sample Output<\/h3>\n<p>a is less than b<br \/>\nThe expression a &lt; b evaluates to = true<\/p>\n<h3>Screenshot<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4871\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Less-than-Operator.png\" alt=\"\" width=\"1737\" height=\"957\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Less-than-Operator.png 1737w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Less-than-Operator-300x165.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Less-than-Operator-1024x564.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Less-than-Operator-768x423.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Less-than-Operator-1536x846.png 1536w\" sizes=\"auto, (max-width: 1737px) 100vw, 1737px\" \/><\/p>\n<h3>&lt;= Relational Operator<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/\/LessThanEqualToOperatorDemo.java\r\n\/\/www.TestingDocs.com\r\n\r\npublic class LessThanEqualToOperatorDemo {\r\n\r\n  public static void main(String[] args) {\r\n\r\n    int a = 10;\r\n    int b = 10;\r\n\r\n    if(a&lt;=b) {\r\n      System.out.println(\"a is less than or equal to b\");\r\n    }\r\n    else {\r\n      System.out.println(\"a is not less than or equal to b\");\r\n    }\r\n    System.out.println(\"The expression a &lt; b evaluates to = \" +(a&lt;=b));\r\n  }\r\n}<\/pre>\n<!--themify_builder_content-->\n<div id=\"themify_builder_content-2738\" data-postid=\"2738\" class=\"themify_builder_content themify_builder_content-2738 themify_builder tf_clear\">\n    <\/div>\n<!--\/themify_builder_content-->\n","protected":false},"excerpt":{"rendered":"<p>Introduction Relational operator Less Than (&lt;) and the operator Less Than Equal to (&lt;=) compares two variables for the relation less than or less than equal to. &lt; Relational Operator a &lt; b evaluates to true if a is less than b else false Similarly, a &lt;= b evaluates to true if a is less [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-2738","post","type-post","status-publish","format-standard","hentry","category-java","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/2738","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=2738"}],"version-history":[{"count":3,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/2738\/revisions"}],"predecessor-version":[{"id":19726,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/2738\/revisions\/19726"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=2738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=2738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=2738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}