Please enable JavaScript.
Coggle requires JavaScript to display documents.
Java (overview (java is:) (object-oriented, platform independent, simple,…
Java
-
Java Identifiers
all Java components require names. names used for classes, variables and methods are called identifiers.
all identifiers should begin with a letter (A to Z or a to z) , currency ($) or an underscore(_).
after the first character, identifiers can have any combination of characters.
-
-
eg of legal identifiers: age, $salary, _value, __1_value.
eg of illegal identifiers: 123abc, -salary.
Basic java syntax
-
class names
the first letter for all class names should start with Upper case letter. if several words are used to form the name of the class, each inner word's first letter should be in Upper Case
Eg: class MyFirstJavaClass
Method names
All method names should start with Lower Case Letter. if several words are used to form the name of the method, then each inner word's first letter should be in Upper Case.
Eg: public void myMethodName()
Program File Name
Name of the program file should exactly match the class name.
Eg; assume 'MyFirstJavaProgram' is the class name. then the file should be saved as 'MyFirstjavaprogram.java'.
-
Java program consist of:
Object
objects hv states and behaviors. Eg; a dog has states - color,name as well as behavior such as wagging their tail, barking,eating. An object is an instance of a class.
class
a class can be defined as a template/blueprint that describes the behavior/state that the object of its type supports.
methods
a method is basically a behavior. a class can contain many methods. here is where the logics are written, data is manipulate and all the actions are executed.
instance variables
each object has its unique set of instance variables. an object state is created by the values assigned to these variables.