COMPSCI 61B Lecture Notes - Lecture 1: Semicolon
Document Summary
Hello world: all code in java must be a part of a class. We delimit the beginning and end of segments of code using { and } All statements in java must end in a semi-colon: create main method inside the class for code to run. Static typing: must declare the variable and set the variable. Must specify a type and a name (ex. Int x: once a type is speci ed, it can never change, types are veri ed before the code even runs. Gets a certi cate of correctness before code can even run. Declaring functions: function must also be in class. Function that is part of a class is called a method so all functions in java are methods: syntax. Parameters of a function must have a declared type as well as the return value: main code runs program, functions in java return only one value, comments on code describing the function is convention.