Java Basic 1
Java Basic 1
What is Java?
Java is a popular programming language, created in 1995.
It is used for:
Java Syntax
In the previous chapter, we created a Java file called MyClass.java, and we used
the following code to print "Hello World" to the screen:
Explaination:
Every line of code that runs in Java must be inside a class. In our example, we
named the class MyClass. A class should always start with an uppercase first
letter.
Remember Note:
➢ Java is case-sensitive: "MyClass" and "myclass" has different meaning.
➢ The name of the java file must match the class name.
➢ The main() method is required and you will see it in every Java program.
➢ Any code inside the main() method will be executed.
➢ that every Java program has a class name which must match the
filename.
➢ every program must contain the main() method.
System.out.println()
System.out.println("Hello World");
type variable
int myNum = 5;
Recommendation :
All Java variables must be identified with unique names.
Identifiers can be short names (like x and y) or more descriptive names (age,
sum, total Volume).