What Is Java - BACK UP
What Is Java - BACK UP
JAVA
Java Is a high-level programming language design in
the early 1990’s by Sun Microsystem, currently owned
by Oracle but develop by James Gosling he is
Canadian computer scientist.
Java is platform independent , which means that you
only need to write the program once to be able to run
it on a number of different programs
Java is portable, robust, and dynamic, with the ability
to fit the needs of virtually any type of application
The Java Story!
Java was developed at Sun Microsystems, Inc. (Sun) by
James Gosling.
Sun microsystem was an American technology that sold the
computers, computer components, software and information
technology services and created the JAVA
PROGRAMMING LANGUAGES
The language needed to be small, fast, reliable, and portable
(hardware independent).
Portable and Platform-Independent
Dynamically Linked
Java Program
In Java, every line of code that can actually run needs to be inside a class
<program statement>
}
}
In Java program, each application has an entry point , or a
starting point, which is the method called MAIN
Along with main, the keywords public and Static will be
explain later.
class MyClass {
public static void main(String[ ] args) {
System.out.println("I am learning Java");
}
}
Example
OUTPUT:
In this program, two
integers 10 and 20 are stored in integer
variables first and second respectively.
Then, first and second are added using
the + operator, and its result is stored
in another variable sum.
Finally, sum is printed on the screen
using println() function.
Variables
Variables have types.
Some examples of Data type
- int: for integers (whole numbers) such as 123 and -456
- double: for floating-point or real numbers with optional decimal points and fractional parts in
fixed or scientific notations, such as 3.1416, -55.66.
- String: for texts such as "Hello" or "Good Morning!". Text strings are enclosed within double
quotes.
Example: String name = "David"; name is the variable that hold the value “David”
It is important to note that a variable is associated with a type, and is only capable of storing values of that particular type. For example,
an int variable can store integer values, such as 123; but it cannot store real numbers, such as 12.34, or texts, such as "Hello".
Examples
Examples of variable declarations:
class MyClass {
You can use a comma-separated list to declare more than one variable of the
specified type. Example: int a = 42, b = 11;
Sample output:
Activity time
Things to consider
“ what data type should we use for your NAME
What data type should we use to for your AGE
What are the variable we will use to name our value of NAME and AGE
What should be our class Name?