{"id":1057,"date":"2019-07-21T21:47:45","date_gmt":"2019-07-21T21:47:45","guid":{"rendered":"http:\/\/kabiliravi.com\/?page_id=1057"},"modified":"2019-07-22T03:17:44","modified_gmt":"2019-07-22T03:17:44","slug":"byte-in-java","status":"publish","type":"page","link":"http:\/\/kabiliravi.com\/index.php\/software\/programming\/my-java-tutorial\/java-basic-syntax\/primitive-data-types\/byte-in-java\/","title":{"rendered":"Byte in Java"},"content":{"rendered":"\n<p>In this sample&nbsp;<strong>TryByte.java<\/strong>, you will learn how to define a variable that has <strong>byte<\/strong> type. You will also learn how to set its value.<\/p>\n\n\n\n<p>Save following content in a .java file called&nbsp;<strong>TryByte.java<\/strong>. Note&nbsp;that the file name is equivalent to your class name&nbsp;<strong>TryByte<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">public class TryByte {\n   public static void main(String[] args) {\n      byte minByte = -128;\n      System.out.print(\"minByte value: \");\n      System.out.println(minByte);\n\n      byte maxByte = 127;\n      System.out.print(\"maxByte value: \");\n      System.out.println(maxByte);\n   }\n}<\/pre>\n\n\n\n<p>Using\u00a0<strong>javac<\/strong>\u00a0command compile your .java file<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ javac TryByte.java<\/pre>\n\n\n\n<p>And using\u00a0<strong>java<\/strong>\u00a0command run it. You will see two printed phrases there which shows two values for two <strong>byte<\/strong> variables\u00a0<strong>minByte<\/strong>\u00a0and\u00a0<strong>maxByte<\/strong>. The value of\u00a0<strong>minByte<\/strong>\u00a0has the <strong>minimum value<\/strong> that a <strong>byte<\/strong> variable can have and that is <strong>-128<\/strong>, while the value of\u00a0<strong>maxByte<\/strong>\u00a0is true has the  maximum value that a <strong>byte<\/strong> variable can have.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ java TryByte\nminByte value: -128\nmaxByte value: 127<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this sample&nbsp;TryByte.java, you will learn how to define a variable that has byte type. You will also learn how to set its value. Save following content in a .java file called&nbsp;TryByte.java. Note&nbsp;that the file name is equivalent to your class name&nbsp;TryByte. public class TryByte { public static void main(String[] args) { byte minByte = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":951,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ngg_post_thumbnail":0,"footnotes":""},"class_list":["post-1057","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/1057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/comments?post=1057"}],"version-history":[{"count":12,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/1057\/revisions"}],"predecessor-version":[{"id":1073,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/1057\/revisions\/1073"}],"up":[{"embeddable":true,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/951"}],"wp:attachment":[{"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/media?parent=1057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}