Course Content
Introduction to Java
Note
Java is not a simple programming language. If you are unfamiliar with other programming languages and OOP principles, this course may be difficult.
Java is a general-purpose programming language. You can use Java virtually for every programming task, such as solving mathematical problems and developing desktop software applications, websites, and games.
Pros | Cons |
Simple | Slow |
Object-oriented | Not attractive |
Secure | No backup facility |
Platform independent | Requires memory space |
Economical | Complex codes |
Portable | |
Stable |
Installing Java
You can download and install Java from the Oracle site.
Writing your first Java code
Let's write the most straightforward Java code.
We use System.out.println()
, a method in Java or a statement used to display a message, data, or string on the screen as the output.
Main.java
In Java, the semicolon (;
) is used to mark the end of a statement. It is used to separate multiple statements on a single line or to terminate a single statement.
Here's an example of using semicolons to separate multiple statements on a single line:
Main.java
Code explanation
- The code inside the Java class goes between the two brackets -
{}
; - Your Java code can have many Java classes. But at least one class should have the
main(String[] args)
method. Java compiler starts executing your program from themain
method;
If you work outside our platform to run this code, copy it to a text editor and save it as hello.java
. Every Java file should end with the .java extension. After that, open your command line and run the following two commands.
javac hello.java
- command will convert the java code into a byte code;java hello
- command will execute java code;
Once you run this code, Java will output "Hello World"
on your console.
Which of the following are Java advantages?
Select a few correct answers
Java compiler first looks for the ___ method...
Select the correct answer
Section 1.
Chapter 1