Java Elementary Programming Instructions - Engl393
Java Elementary Programming Instructions - Engl393
Java Elementary Programming Instructions - Engl393
Loc Trieu
Christopher Justice
ENGL393 Section: 03
13 April 2024
Table of Contents
1. Introduction______________________________________________3
2. Basic Vocabulary__________________________________________4
3. If-Else Statements_________________________________________6
4. Looping Structures________________________________________7
5. Conclusion Statement______________________________________8
6. Glossary_________________________________________________9
2
1.0 Introduction
- Laptop/Desktop or PC
- Working Internet Connection
3
1.2 Software Download - IntelliJ
Figure 1.2.1.(a) Image of the Download button Figure 1.2.1(b) Image of the download options
2.) Click the .dmg tab and select “Intel” if the computer runs on windows, and click “Apple
Silicon”.
3.) Proceed to Download.
4.) Go to Downloads and click on the “ideaIC-2023.3.3.dmg” folder to run the software.
5.) Once you have the Software open, click “new project” to start coding.
Note that the rest of the code in this guide will be written within the main method
brackets.
2.) Next, we are going to write a simple program.
4
3.) Run the program and the following should show up in the terminal.
4.) That is all there is to it. In the following sections we will be building onto this, making
even more complex code.
3.) Then, run the program and the following should show in the terminal.
5
Figure 2.2.1 Java Terminal
For naming conventions, the “a” , “b”, “c”, “d” can be named anything the user wants, but no
matter what they have to start as a lowercase or in camel case. This is done so that in the future,
when looking back at a code, anyone looking would know that the variable is a named variable
that was made up, and not instead something within the language.
Examples include:
- “a”
- “name”
- “age”
- “nameAndAge”
The relational operator in this example would be “b < 5” and it is true. Because the condition is
met, only the block of code within is executed. If the condition is not met, the program goes on
to the else statement.
6
Keep in mind that there are many comparators that we can use:
- “a < 5” A is less than 5
- “a > 5” A is greater than 5
- “a == 5” A is equal to 5
- “a >= 5” A is greater than or equal to 5
- “a <= 5” A is less than or equal to 5
2.) Run the program and the following should display in the terminal.
In this example, “int a = 0;” is the initializer. The condition for the while loop is “a < 5”. The
iterator is “a++”. The logic of the code is as follows, “a” at first is zero, then the program gets to
the while loop. Since zero is less than five, the code in the loop executes. The program prints
“hello “ once, then with “a++”, ‘a’ gets iterated to become 1, then the program loops back to the
beginning of the while loop. Since one is less than five, the code inside the while loop iterates
again. This keeps going until ‘a’ becomes five. Once ‘a’ becomes five, ‘a’ is not less than five, so
the program continues past the loop.
7
4.2 For Loops
For loops are a more structured way of doing while loops. The parameters are the same, and the
logic is the same.
1.) Type the following into a new main method
2.) Run the program and the following should show in the terminal
Notice that there is also an initializer, a relational operator and an iterator, but instead, are all in
the for loop header. For loops work exactly the same as while loops, but there structure provide
different specific situations that are applicable to higher levels of java programming.
Figure 4.2.2 Diagram Comparison between For Loops and While Loops
This concludes the introductory Java Object Oriented Programming Guide. This is the most basic
guide that teaches every structure needed to build software. As you progress into higher levels of
Java, you will see that every new concept is just a deviation of these main components. By
understanding the basic building blocks, this will provide good fundamentals for Java
Programming.
8
6.0 Glossary
Camel Case
- A naming convention style. When a series of words are used as a variable, the first word
is lowercase, and every proceeding word starts with an uppercase. I.e leoLikesRice
For Loops
- Looping structure where the iterator, relational operator, and iterator are in the header
If-Else Statements
- Code structure where a series of relational operators are stated, and whichever
conditions are met, the proceeding code is the code that is run.
Initializers
- Key component in looping structures. Sets the starting point of a looping statement.
Iterators
- Key component of looping structures that count the number of loops
Relational Operators
- Used in many key Java methods and structures. Allows for the comparison of values so
that the programmer can manipulate the code and to act a certain way based off the
comparisons
While Loops
- Looping structure that allows for whatever block of code inside to repeat itself. Necessary
components are an iterator, initializer, and relational operator.