Say What? Basic Java Terms and Syntax

Coding is essentially a foreign language. Everything looks like gibberish if you don't know what things mean. Below is a list of syntax and terms that you should become familiar with in order to succeed in learning basic Java code. It is important to know that Java syntax is case sensitive, so you need to know if words should be uppercase or lowercase, otherwise your code will not work!


Object - objects have states and behaviors, they are the instance of the class. Ex. humans have states, such as height, weight, hair color, and behavior such as eating, talking, etc.

Class - defined as a template/blueprint that describes the states and behaviors of objects

Class Names - for all class names in Java the first word needs to be capitalized; if more than one word make up a class name then each inner word's first letter should be capitalized
          ex. class MyFirstJavaClass

Method - a collection of statements that are grouped together to preform a task; there can be more than one method within a class

Method Names - all method names should start with a lower case letter; if there is more than one word in a method name then each inner word's first letter should be capitalized
          ex. public void myMethodName()

Instance Variables - used by objects to store their states

Case Sensitivity - Java is case sensitive meaning "Hello" and "hello" will have a different meaning

int - a data type that means integer/number; cannot include decimals

String - a sequence of characters that can be output into a sentence
          ex. System.out.println("hi there everyone");

double - a number data type (similar to int) that CAN contain decimals

public static void main(String args[]) - Java program processing starts with a main() method which is a mandatory part of every program

Program file name - name of the program file (should match the name of the class exactly); when saving a file take your class name and add ".java" to the end of it; if your class name and program file do not match your program will not compile
          ex. MyFirstJavaClass.java

Array - a container object that contains a fixed number of variables of the same type; the number of variables is declared upon creation of the array
          ex. int a[] = new int[5]
                a[0] = 2;
                a[1] = 5;
                a[2] = 4;
                a[3] = 7;
                a[4] = 12;

Boolean - a comparison: true or false, yes or no, 1 or 0; your code can execute so that if one thing happens then the output says true, and if something other than your desired outcome occurs then it is false

 ! - means not/the opposite of what is written; used in boolean expressions (example: != means "not equal")


== - means exactly equal
  
++ - default to add one (1) each time the action is repeated

Loop - statement that allows you to execute a statement or a group of statements multiple times (see image below)

Comments

Popular Posts