JAVA Tutorial (Oni Blessing)
JAVA Tutorial (Oni Blessing)
By
Oni Blessing
What is JAVA?
JAVA is an object oriented language that
interprets using the JAVA virtual machine to
implement programs on the computer.
Basics Of JAVA Programing
• JAVA Fundamentals
• Classes an objects
• Method
• inheritance
JAVA Fundamentals
keywords:this are RESERVED words used in the program
(public,static,if,else,privatee.t.c)
Identifiers:They have some attributes
• sequence of one or more characters(N,n,hello)
• An identifier cannot be a keyword or true, false, or null.
• An identifier can consist of letters, digits 0–9, the underscore, or
the dollar sign.(x15)
• An identifier must start with a letter, an underscore, or a dollar
sign(long_name_i)
Data types:this are memories in which data are
stored(int,char,float,boolean,double)e.t.c
Control Structure: This consist of the loop
operations{if/else,switch,do/while,boolen
operators(>,<,&&,<+)}e.t.c
Classes and Object
System.out.println("Hello World!");
}
public class program-name
optional-variable-declarations-and-subroutines
statements
optional-variable-declarations-and-subroutines
}
Workshop
How many fields does the Date class have? How
many methods?
Program
public class Date
return day;
}
Anwser
The Date class has 3 fields and 3 Methods.
Field
int: day, month, and year,
Method
getDay() and printDate()
As you can see the program in the workshop
does not have a main.
For this program this main is called from another
public class. See the next slide for more
understanding.
Fig: Method
public class DateProgram
System.out.println(“Within main...”);
today.day = 25;
today.month = 12;
today.year = 2003;
today.printDate();
today.getDay();
}
Expalnation