course content

Course Content

Introduction to Java

What is Java?What is 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.

ProsCons
SimpleSlow
Object-orientedNot attractive
SecureNo backup facility
Platform independentRequires memory space
EconomicalComplex 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.

java

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:

java

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 the main 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.

1. Which of the following are Java advantages?
2. Java compiler first looks for the ___ method...

question-icon

Which of the following are Java advantages?

Select a few correct answers

question-icon

Java compiler first looks for the ___ method...

Select the correct answer

Section 1.

Chapter 1