Introduction
What is Java?
Java is one of the most popular and in-demand programming languages to learn. Thanks to its platform independence and multiplatform support, Java is a staple programming language of the IT and software sectors. Companies are always on the lookout for skilled Java Developers who can develop innovative Java projects.
Java is used for:
- Mobile applications (especially Android apps)
- Desktop applications
- Web applications
- Web servers and application servers
- Games
- Database connection
- And much, much more!
Java Installation
Some PCs might have Java already installed.
To check if you have Java installed on a Windows PC, search in the start bar for Java or type the following in Command Prompt (cmd.exe):
|
C:\Users\Your Name>java -version |
If Java is installed, you will see something like this (depending on the version):
| java version "11.0.1" 2018-10-16 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode) |
If you do not have Java installed on your computer, you can download it for free at oracle.com.
Note: In this tutorial, we will write Java code in a text editor. However, it is possible to write Java in an Integrated Development Environment, such as IntelliJ IDEA, Netbeans, or Eclipse, which are particularly useful when managing larger collections of Java files.
Setup for Windows
To install Java on Windows:
- Go to "System Properties" (Can be found on Control Panel > System and Security > System > Advanced System Settings)
- Click on the "Environment variables" button under the "Advanced" tab
- Then, select the "Path" variable in System variables and click on the "Edit" button
- Click on the "New" button and add the path where Java is installed, followed by \bin. By default, Java is installed in C:\Program Files\Java\jdk-11.0.1 (If nothing else was specified when you installed it). In that case, You will have to add a new path with C:\Program Files\Java\jdk-11.0.1\bin
Then, click "OK", and save the settings - At last, open Command Prompt (cmd.exe) and type java -version to see if Java is running on your machine
Java Variables
Variables are containers for storing data values.
In Java, there are different types of variables, for example:
- String - stores text, such as "Hello". String values are surrounded by double quotes
- int - stores integers (whole numbers), without decimals, such as 123 or -123
- float - stores floating-point numbers, with decimals, such as 19.99 or -19.99
- char - stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes
- boolean - stores values with two states: true or false
Task
The java programming language has now been introduced to you, and it is expected to be installed on your computer.
I have created a compilation of simple codes you should try to run on your computer with links to youtube videos.
Watch the videos to help you complete the activities that follow to the best of your ability.
**SUBMISSION: Type out your name and send screenshots of the results on a word document and send it to the following email: hh123456789@gmail.com, by 30 February 2022 at 12:00.**
Process
Open your java software(e.g Netbeans) try the following code and send the screenshots of results in my email.
|
Program 1. Hello world public class FirstProject { public static void main(String[] args) { System.out.print("Hello, World"); System.out.println(); } } |
|
Program 2. Arithmetic and Assignment Operators public class Main { |
|
Program 3 public class Main { |
Evaluation
| Total | Needs improvement | Good | Excellent | |
|
Program 1 |
10 |
0-3 Did not submit the results. |
4-6 Submit the results but the code has an error and/or didn't run. |
7-10 The program runs correctly. |
|
Program 2 |
10 |
0-3 Did not submit the results. |
4-6 Submit the results but the code has an error and/or didn't run. |
7-10 The program runs correctly. |
|
Program 3 |
10 |
0-3 Did not submit the results. |
4-6 Submit the results but the code has an error and/or didn't run. |
7-10 The program runs correctly. |
Conclusion
Java is one of the most popular programming languages in the world since it is easy to learn and simple to use, it is open-source and free and it is working on different platforms.
There are various tutorials you can watch on youtube or read on the website for you to start coding.
Credits
Program 1 Hello World
Program 2