EECS 1021 Chapter Notes - Chapter 2: Grammar, Computer Programming, Part Of Speech
Document Summary
The basic concepts of the java language structure. The primitive java data types and how they are used. Java program bmi example: public class bmicalculator { // declare variables double weight; double height; double bmi; public bmicalculator(double w, double h) { weight = w; height = h; public double calculatebmi() { return weight / (height * height); // this is our main method. public static void main(string[] args) { Statements can start any place of indentation; same idea for extra whitespace, tabs and new lines (the complier ignores it) Improve readability of code by using consistent format style. Each statement must end with semicolon (;) Definition: class is a code container, access modifier specifies which classes have access to it (examples of access modifiers are public, private, etc) The name of the class is followed by the word class. The class definition is enclosed within brackets {: every class definition consists of both variables and methods.