Java
is an object oriented programming language
Java is accompanied with the Java API or standard class library
Developed in early 1990s by James Gosling at Sun Microsystems which is currently owned by Oracle
Standard Class Library
the standard class library or Java API is provided software/code that gives you the ability to create graphics, communicate over networks, and interact with databases, among other features
Java Virtual Machine (JVM)
The JVM has two primary functions: to allow Java programs to run on any device or operating system (known as the "Write once, run anywhere" principle), and to manage and optimize program memory.
The JVM makes it possible to translate bytecode into machine code
What is needed to run Java?
javacjavadocjar

Match the command with the description to the right by dragging and dropping term into box.
main()Main() methodConstant
Cannot be changed after a program is compiled. Utilize keyword "final"
Literal constant
Its value is taken literally at each use
Variable
A named location in computer memory that can hold different values at different points in time
Data Type
Describes the format and size of (amount of memory occupied by) a data item
Primitive Types
types that are self contained and holds atomic value; Types without any fields or methods; Types do not inherit Object. Primitive data types are also called simple types
Unicode
is the system that provides a numeric value for every character.
What does it mean by signed and unsigned? What's the difference between bit and bytes?
Think of a number between 1 - 60
Do not share this number with the instructor. The instructor will magically guess your number
How did I guess the number?
Patterns?
Are there any recognizable patterns you observe from the chart to the right?
Decimal to Binary
Convert the number 92 and 203 into Binary
Binary to Decimal
What is the decimal value of 10010110?
What is the decimal value of 0110101?
class Program
{
static void aMethod()
{
//Using primitive data type
double monthlySalary = 9200.00;
//Using Var keyword
var yearlySalary = monthlySalary *12;
System.out.println(yearlySalary);
}
}
Java lets you declare local variables without giving them explicit types. The data type is implied at runtime.
Syntax Errors
Logical Errors
Run-time Errors
When compiling and running a program, any of the three errors can occur.
Step 1
Open the terminal
Step 2
Make sure you in the directory you want to compile source code
Step 3
Enter the commandjavac [NAME_OF_FILE].java to compile
Step 4
type the Dir command to view files (this step is not necessary for compiling)
Step 5
Type java [NAME_OF_FILE] and press Enter to run the program. * Make sure to leave .java off
public class Movie{
public static void main(String[] args) {
string marvelMovie = "The Avengers Infinity War"
System.out.printLine(marvelMovie + " is the best Marvel Movie");
}
public class Movie{
public static void main(String[] args) {
String marvelMovie = "The Avengers Infinity War";
System.out.println(marvelMovie + " is the best Marvel Movie");
}
}
public class Discount{
public static void main(String[] args) {
double price = 23.00;
double discount = .10;
price = discount *(price - 1);
System.out.println("With discount the price is " + price);
}
}
public class Discount{
public static void main(String[] args) {
double price = 23.00;
double discount = .10;
price = (1 - discount) * price;
System.out.println("With discount the price is " + price);
}
}
public class Calculations{
public static void main(String[] args) {
int number1 = 32, number2 = 0, result = 0;
result = number1/number2;
System.out.println("The result is" +result);
}
}
public class Calculations{
public static void main(String[] args) {
int number1 = 32, number2 = 0, result = 0;
try{
result = number1/number2;
System.out.println("The result is" +result);
}
catch(ArithmeticException e) {
System.out.println ("Can't be divided by Zero " + e);
}
}
}
class Program{
public static void main(String[] args){
//Using primitive data type
double monthlySalary = 9,200.00;
//Using Var keyword
var yearlySalary = monthlySalary *12;
System.out.println(yearlySalary)
}
}
How many errors do you observe in the code above?
public class Program{
public static void Main(String[] args){
//Annual Salary
double annualSalary = 92003.14;
//Calculate the monthly Salary
double monthlySalary = annualSalary * 12;
System.out.println("Monthly Salary: $" + monthlySalary);
}
}
Using the code above, which option represents the error in the code?
To implement the Scanner class, you must import import java.util.*;package
The Scanner class allows for input operations - reading input from the console
import java.util.Scanner;
public class Program{
public static void main(String[] args){
//Declarations
String name, program;
int creditHours;
double tuitionCost;
final double TUITION = 780.00;
Scanner scn = new Scanner(System.in); // Create a Scanner object
System.out.println("Please enter your name: ");
name = scn.nextLine();
System.out.println("Please enter program: ");
program = scn.nextLine();
System.out.println("Please enter number of credits for this semester: ");
creditHours = scn.nextInt();
tuitionCost = TUITION * creditHours;
System.out.println(name + " Thank you for entering your information. \n" +
"Your tuition for the semester is: " + tuitionCost);
}
}
The System package is imported by default, no need for an import statement
The System class offers access to input/output operations, but can also provide access to system level information.
import java.util.Scanner;
class Program{
static void Main(String[] args){
long startTime = System.nanoTime(); //Gets the time before evaluating next statements
System.out.println("Your System properties");
System.out.println("**********************");
Properties p = System.getProperties(); //Creating a new instance of
System.out.println("User name: " + p.getProperty("user.name")); //get User's account name
System.out.println("User home directory: " + p.getProperty("user.home")); //get User's home directory
System.out.println("User current working directory: " + p.getProperty("user.dir")); //get User's current working directory
System.out.println("User Operating System: " + p.getProperty("os.name")); //get operating System
System.out.println("User Operating System version: " + p.getProperty("os.version")); //get operating system version
long elapsedTime = System.nanoTime() - startTime; //Calculate after executing getProperty() statements
// 1 second = 1_000_000_000 nano seconds
double elapsedTimeInSecond = (double) elapsedTime / 1_000_000_000;
System.out.println("Time in seconds it took to execute program: " + elapsedTimeInSecond + " seconds");
}
}
Gaining inspiration from the previous slide, create a program that calculates the time it takes you to type out the teams "White Sox, Cubs, Sky, Bears, Fire, Blackhawks, Bulls " Your program should operate and function similar to the program below.
Step 1
Declare variables need for program and create Scanner object instance
Step 2
Create statement to start the timer and display the teams and accept input
*Review previous slide
Step 3
Calculate the starttime from endtime, get time in seconds and display output message

The task of keeping a software system consisting of many versions and configurations well organized.
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
git --versionThe cheatsheet represents some of the most used commands that allow you to achieve the Git workflow.
Click here for an exhaustive book on git commands
Going through this workflow allows us to keep track of the changes we are making.
public class App{
public static void main(String[] args) {
double price = 23.00;
double discount = .10;
price = (1 - discount) * price;
System.out.println("With discount the price is " + price);
}
}
For this activity, we'll keep track of the changes we make to a simple java program
Step 1
Create a new Java program and copy the code above into your source code -> Open the folder and right-click to open git bash terminal-> initialize git inside of project folder and make first commit.
Step 2
Create a public repository on GitHub.com and copy instructions to push existing code to repository
Step 3
Run the git status command and make sure your directory does not have untracked files and to make sure branch is clean.
Navigate back to the the terminal and paste commands to push code up.
1. git init -> Initializes git into project folder
2. Make the necessary changes to the application. Save the file and render in browser to observe added functionality.
3. git status -> Checks the status to see status of files in directory
4. git add . -> Adds files to staging area. In preparation to be committed.
5. git status -> Check status again to see if file(s) were added to staging area.
6. git commit -m "adding category" -> Document the change by committing changes and adding a brief message.
7. git log -> To view commit history and timestamp.
Match the command with the description to the right by dragging and dropping term into box.
Branching allows you to create a copy of your main branch. You can experiment and test new functionality on new branches. Branching allows you to keep your main branch clean.