{"id":11314,"date":"2015-07-07T19:08:55","date_gmt":"2015-07-07T19:08:55","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=11314"},"modified":"2015-07-07T19:11:32","modified_gmt":"2015-07-07T19:11:32","slug":"java-programming-the-pizza-class-continued","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/java-programming-the-pizza-class-continued\/","title":{"rendered":"Java programming:  the Pizza class, continued"},"content":{"rendered":"<h1>The tutor continues with some points about Java classes.<\/h1>\n<p>In my <a href=\"?p=11299\">previous post<\/a> I introduced a Java class called Pizza.  Here are a few points that might come to mind to someone new to the topic:<\/p>\n<ol>\n<li>The class name is capitalized by convention.  In Java, classes have capitalized names, while methods have lower case names (with one exception which we&#8217;ll visit soon:).  Furthermore, a class file must be saved as <span style=\"font-family:monospace\"><i>classname<\/i>.java<\/span> for the compiler to be happy.  This file must be saved as <span style=\"font-family:monospace\">Pizza.java<\/span> for that reason.<\/li>\n<p><\/p>\n<li>This Pizza class won&#8217;t &#8220;run&#8221;.  From a C or Perl point of view, it&#8217;s not a program; rather, it&#8217;s more like a data structure.  A simple perspective suggests it won&#8217;t run because it lacks a <span style=\"font-family:monospace\">main<\/span> method.  Therefore, to be put into action, it depends on another class that has a <span style=\"font-family:monospace\">main<\/span> method.<\/li>\n<p><\/p>\n<li>The capitalized method <span style=\"font-family:monospace\">Pizza(String[] toppingslist)<\/span> inside the class Pizza is a <em>constructor<\/em>.  A constructor is a method used to create an instance of a class, simultaneously giving values to certain of its fields (aka variables).  The Pizza class constructor accepts an array called <span style=\"font-family:monospace\">toppingslist<\/span>, which serves to identify its toppings.<\/li>\n<p><\/p>\n<li>The fact that the method <span style=\"font-family:monospace\">describeMe()<\/span> is public means it can be called freely by other classes that want to use it.<\/li>\n<p><\/p>\n<p>The rest of the code in the Pizza class involves specific instructions from the Java language.  I&#8217;ll illuminate a few points towards it in future posts:)<\/p>\n<p>Source:<\/p>\n<p><a href=\"https:\/\/docs.oracle.com\/javase\/tutorial\/java\/javaOO\/classes.html\">docs.oracle.com<\/a><\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The tutor continues with some points about Java classes. In my previous post I introduced a Java class called Pizza. Here are a few points that might come to mind to someone new to the topic: The class name is &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/java-programming-the-pizza-class-continued\/\"> <span class=\"screen-reader-text\">Java programming:  the Pizza class, continued<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[919,761,602],"class_list":["post-11314","post","type-post","status-publish","format-standard","hentry","category-computer-science","tag-constructor","tag-java","tag-java-programming"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/11314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=11314"}],"version-history":[{"count":21,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/11314\/revisions"}],"predecessor-version":[{"id":11335,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/11314\/revisions\/11335"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=11314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=11314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=11314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}