JavaProgrammingForBeginners-Presentation-1-15
JavaProgrammingForBeginners-Presentation-1-15
For Beginners
New Sections: Java New Features (10,..,15,16,..), Spring,
Spring Boot and REST API
1
Learn Java Programming
GOAL: Help YOU learn Programming
Basics and Best Practices
Problem Solving
Simple Design and Debugging
Help you have fun!
APPROACH: Hands-on Step By Step
Learn Problem Solving
Practice 200+ Code Examples
Test Your Learning: Exercises
Learn to Debug Programs : Github Page
Build real world applications
By the end of the course, you will be a
really good programmer!
2
YOUR Success = OUR Success
3
4
Installing Java
Step 01: Installing Java on Windows
Step 02: Installing Java on MacOS
Step 03: Installing Java on Linux
Step 04: Troubleshooting
Alternative:
https://tryjshell.org/
5
Programming and Problem Solving
I love programming:
You get to solve new problems every day.
Learn something new everyday!
Steps in Problem Solving:
Step I: Understand the Problem
Step II: Design
Break the Problem Down
Step III: Write Your Program (and Test)
Express Your Solution: Language Specifics (Syntax)
6
Challenge 1 : Print Multiplication Table
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
7
Where do we start? : Print Multiplication Table
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
8
JShell
Do you know?: How do Python programmers start learning
Python?
Python shell: That's why Python is easy to learn
From Java 9: Java is equally easy to learn - JShell
Java REPL (Read Eval Print Loop)
Type in a one line of code and see the output
Makes learning fun (Make a mistake and it immediately tells you whats wrong!)
All great programmers make use of JShell
9
Java Primitive Types
Type of Java Size Range of Values Example
Values Primitive (in
Type bits)
10
Print Multiplication Table - Solution 1
jshell> int i
i ==> 0
jshell> for (i=0; i<=10; i++) {
...> System.out.printf("%d * %d = %d", 5, i, 5*i).println();
...> }
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 2
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
11
JVM, JRE And JDK
JRE = JVM + Libraries + Other Components
JVM runs your program bytecode
Libraries are built-in Java utilities that can be used within any program you create.
System.out.println() was a method in java.lang, one such utility.
Other Components include tools for debugging and code profiling (for memory management
and performance)
JDK = JRE + Compilers + Debuggers
JDK refers to the Java Development Kit. It's an acronym for the bundle needed to compile
(with the compiler) and run (with the JRE bundle) your Java program.
Remember:
JDK is needed to Compile and Run Java programs
JRE is needed to Run Java Programs
JVM is needed to Run Bytecode generated from Java programs
12
Installing Eclipse
Most Popular Open Source Java IDE
Download:
https://www.eclipse.org/downloads/packages/
Recommended:
"Eclipse IDE for Enterprise Java and Web Developers"
Troubleshooting
Use 7Zip if you have problems with unzipping
Unzip to root folder "C:\Eclipse" instead of a long path
Guide: https://wiki.eclipse.org/Eclipse/Installation#Troubleshooting
13
Print Multiplication Table - Solution 2
public class MultiplicationTable {
public static void print() {
for(int i=1; i<=10;i++) {
System.out.printf("%d * %d = %d", 5, i, 5*i).println();
}
}
14
Print Multiplication Table - Refactored (No Duplication)
package com.in28minutes.firstjavaproject;
15