Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

JavaProgrammingForBeginners-Presentation-1-15

The document is a beginner's guide to Java programming, covering essential concepts, installation instructions, and practical exercises. It emphasizes hands-on learning with over 200 code examples and aims to build confidence in programming through interactive challenges. Key topics include Java features, problem-solving steps, and the use of tools like JShell and Eclipse for coding.

Uploaded by

gs23133
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

JavaProgrammingForBeginners-Presentation-1-15

The document is a beginner's guide to Java programming, covering essential concepts, installation instructions, and practical exercises. It emphasizes hands-on learning with over 200 code examples and aims to build confidence in programming through interactive challenges. Key topics include Java features, problem-solving steps, and the use of tools like JShell and Eclipse for coding.

Uploaded by

gs23133
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Java Programming

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

98,000+ Learners with 46% 5 STAR Reviews


Last Year: 42,000+ active learners & 14 million learning minutes
"Great mix of theory and exercises!"
"Interactive learning with the help of puzzles"
"Never thought taking an online course will be so helpful. "
"Builds confidence in people who fear programming"
RECOMMENDATION: Bit of Patience in the first hour!

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)

Let's solve multiple problems step by step!


Learning to Program = Learning to ride a bike
First steps are the most difficult
Pure Fun afterwards!

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

Step 1: Calculate value of "5 * 5"


Step 2: Print "5 * 5 = 25"
Step 3: Do this 10 times

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

In this course: We use JShell to get started


By Section 5, you will be comfortable with Java syntax
We will start using Eclipse as the Java IDE!

9
Java Primitive Types
Type of Java Size Range of Values Example
Values Primitive (in
Type bits)

Integral byte 8 -128 to 127 byte b = 5;

Integral short 16 -32,768 to 32,767 short s =


128;

Integral int 32 -2,147,483,648 to 2,147,483,647 int i =


40000;

Integral long 64 -9,223,372,036,854,775,808 to long l =


9,223,372,036,854,775,807 2222222222;

Float float 32 ±3.40282347E+38F. NOT precise float f =


4.0f

Float double 64 ±1.79769313486231570E+308. NOT precise double d = 67.0

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();
}
}

public static void print(int number) {


for(int i=1; i<=10;i++) {
System.out.printf("%d * %d = %d", number, i, number*i).println();
}
}

public static void print(int number, int from, int to) {


for(int i=from; i<=to;i++) {
System.out.printf("%d * %d = %d", number, i, number*i).println();
}
}
}

14
Print Multiplication Table - Refactored (No Duplication)
package com.in28minutes.firstjavaproject;

public class MultiplicationTable {


public static void print() {
print(5, 1, 10);
}

public static void print(int number) {


print(number, 1, 10);
}

public static void print(int number, int from, int to) {


for(int i=from; i<=to;i++) {
System.out.printf("%d X %d = %d", number, i, number*i).println();
}
}
}

15

You might also like