Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and...

100
www.duckademy.com Learn Java in an easy and entertaining way

Transcript of Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and...

Page 1: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

www.duckademy.com

Learn Java in an easy and entertaining way

Page 2: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Video 1

Getting startedwith Java

Page 3: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

The goal of this course is to teach you how to

program in Java. From the very basics, through

lots of exercises, you will get to an advanced level where you can become an expert Java developer.

Page 4: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

The course will cover Getting started with Java Sorting elements in Java

Control structures Generics

NetBeans tips and tricks Variations for storing objects

Basic algorithms Handling exceptions

Arrays File handling

Functions and structured programming

Enums

Object-oriented programming in Java

Using external libraries in our programs

Handling dates and times

Page 5: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

In this video

1. A quick intoduction to Java

2. Install NetBeans

3. Create our first project (Hello, World!)

4. Variables and types

5. Input/output and calculations

6. Conditions (if)

7. Review exercise

Page 6: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

A quick intoduction to Java

Page 7: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

In the TOP 3 (if not the most popular)

3 billion devices run…

Platform independency (writeonce, run anywhere)

Lots of well paying jobs Wide usability

Java is popular

Page 8: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java as a tree

Page 9: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way
Page 10: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Basic computer skills

Page 11: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Basic computer skills

Programming in Java

Basic Java tools

Page 12: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Basic computer skills

Programming in Java

Basic Java tools

Mobile appsAndroid

Java ME (cards, TV…)

Android has the highest, 60% market share among mobile platforms worldwide.

Page 13: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Basic computer skills

Programming in Java

Basic Java tools

Mobile apps

Desktopapps

Android

Games

Java ME (cards, TV…)

Software tools

Scientific research

Page 14: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Basic computer skills

Programming in Java

Basic Java tools

Mobile apps

Desktopapps

Enterprise (”web”) apps

Android

Games

Java ME (cards, TV…)

90% of Fortune 500

companies use Java.

Software tools

Banks

Scientific research

E-commerce applications

Backend services

Page 15: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Basic computer skills

Programming in Java

Basic Java tools

Mobile apps

Desktopapps

Enterprise (”web”) apps

Android

Games

Java ME (cards, TV…)

Software tools

Programming in Java

Banks

Scientific research

E-commerce applications

Backend services

Basic Java tools

In this course

Page 16: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Travelling to Europe...

Page 17: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Travelling to Europe...

Pretty girl!

Page 18: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Pretty girl!

Non capisco niente!

Travelling to Europe...

Page 19: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Non capisco niente!

???

Travelling to Europe...

Page 20: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Translate (compile) the message...

Compiler

Page 21: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Translate (compile) the message...

Compiler

Pretty girl!...Bella ragazza!

Page 22: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Translate (compile) the message...

Pretty girl!...Bella ragazza!

Compiler

Page 23: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Interpreter

Interpret the message...

Page 24: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Interpret the message...

I speak English AND Italian!

Interpreter

Page 25: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Interpret the message...

Pretty girl!

Interpreter

Page 26: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Interpret the message...

Lui dice: „Bella ragazza”.

Pretty girl!

Interpreter

Page 27: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Interpret the message...

Lui dice: „Bella ragazza”.

Pretty girl!

Interpreter

Page 28: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java style (platform independence)

Page 29: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java style (platform independence)

Compiler

Page 30: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java style (platform independence)

Prettygirl!

Compiler

Page 31: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java style (platform independence)

Prettygirl!…

Compiler

Page 32: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java style (platform independence)

Prettygirl!…Bela

knabino!

Compiler

Page 33: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java style (platform independence)

Interpreter

Compiler

I speak ItalianAND Esperanto.

I speak FinnishAND Esperanto.

Prettygirl!…Bela

knabino!

Page 34: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java style (platform independence)

Interpreter

Compiler

Lui dice: „Bella ragazza”

Prettygirl!…Bela

knabino!

Page 35: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java style (platform independence)

Interpreter

Compiler

Prettygirl!…Bela

knabino!

Lui dice: „Bella ragazza”

Page 36: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java style (platform independence)

Interpreter

Compiler

Hän sanoo: „Kaunis tyttö”

Prettygirl!…Bela

knabino!

Lui dice: „Bella ragazza”

Page 37: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java style (platform independence)

Interpreter

Compiler

Hän sanoo: „Kaunis tyttö”

Prettygirl!…Bela

knabino!

Lui dice: „Bella ragazza”

Page 38: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java style (platform independence)

Interpreter

Prettygirl!…Bela

knabino!Byte code

Compiler

Hän sanoo: „Kaunis tyttö”

Lui dice: „Bella ragazza”

Page 39: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java style (platform independence)

Interpreter

Prettygirl!…Bela

knabino!Byte code

Hän sanoo: „Kaunis tyttö”

Lui dice: „Bella ragazza”

Compiler

Virtualmachine

Virtualmachine

Page 40: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

What do we need to startJava programming?

Page 41: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

What do we need to startJava programming?

JRE

Page 42: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

What do we need to startJava programming?

JRE

IDE

Page 43: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

What do we need to startJava programming?

JRE

IDE

JDK

Page 44: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

What do we need to startJava programming?

JRE

IDE

JDK

JVM

Page 45: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

What do we need to startJava programming?

JRE

IDE

JDK

JVM

NetBeans

Page 46: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

What do we need to startJava programming?

JRE

IDE

JDK

JVM

NetBeans

Eclipse

Page 47: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java Development Kit(JDK)

Java Runtime Environment(JRE)

Java VirtualMachine

(JVM)

Integrated DevelopmentEnvironment

(IDE)NetBeans Eclipse

Page 48: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Variables and types

Page 49: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Variables and types

Page 50: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Variables and types

Shirts T-shirts

Page 51: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Variables and types

Underwear

Shirts T-shirts

Page 52: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

Page 53: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

All types

Page 54: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

All typesPrimitive types

Page 55: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

All typesPrimitive types Classes

Page 56: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

All typesPrimitive types ClassesNumbers

Page 57: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

All typesPrimitive types ClassesNumbers

Char

Page 58: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

All typesPrimitive types ClassesNumbers

Char

Boolean

Page 59: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

All typesPrimitive types ClassesNumbers

Char

Boolean

Integer

Page 60: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

All typesPrimitive types ClassesNumbers

Char

Boolean

Integer Real

Page 61: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

All typesPrimitive types ClassesNumbers

Char

Boolean

Integer RealByte

Page 62: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

All typesPrimitive types ClassesNumbers

Char

Boolean

Integer RealByteShort

Page 63: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

All typesPrimitive types ClassesNumbers

Char

Boolean

Integer RealByteShort

Long

Page 64: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

All typesPrimitive types ClassesNumbers

Char

Boolean

Integer RealByteShort

LongInt

Page 65: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

All typesPrimitive types ClassesNumbers

Char

Boolean

Integer RealByteShort

LongInt

Float

Page 66: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Java variables and types

All typesPrimitive types ClassesNumbers

Char

Boolean

Integer RealLong

ByteShort Float

DoubleInt

Page 67: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Replace the value of 2 variables! Don’t write numbers! Don’t change the existing lines, only include new ones!

public class Replace { public static void main(String[] args) { int first = 7; int second = 19; // write something here!!! System.out.println(”first=”+first+” second=”+second); }}

Value replacing exercise

Page 68: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Glass exercise

Page 69: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Glass exercise

?

Page 70: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Glass exercise

Page 71: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Glass exercise

Page 72: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Glass exercise

Page 73: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Glass exercise

Page 74: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Glass exercise

Page 75: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Glass exercise

Page 76: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Input/output and calculations

Page 77: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Temperature exercise Write a program that reads in an integer value

denoting a temperature value in Celsius grade.

Calculate and print the Fahrenheit grade!

What do we not know?– How to read in a number– How to make calculations

° F=95 ° C+32

Page 78: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Boiling exercise Write a program that reads in a temperature value

(in Celsius) and prints out if the water is boiling at the specified temperature!

What do we not know?– How to run a part of code based on a condition

100 °C

Page 79: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Boiling and freezing exercise Write a program that reads in a temperature value (in

Celsius), and prints out whether the water is boiling or freezing or at normal state at the specified temperature!

What do we not know?– Joining if’s

0 °C 100 °C

Page 80: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Logic operators

Page 81: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Logic operators

&&

||

!

Page 82: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

True, if both conditions are true.

Logic operators

&&

||

!

Page 83: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

True, if both conditions are true.

True, if either condition is true.

Logic operators

&&

||

!

Page 84: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

True, if both conditions are true.

True, if either condition is true.

Negate:

Logic operators

&&

||

! makes true out of false

Page 85: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

True, if both conditions are true.

True, if either condition is true.

Negate:

Logic operators

&&

||

!

and false

makes true out of false

out of true.

Page 86: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Conditions (if)

Page 87: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Multiple if-else if-else if-…-else

Page 88: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Multiple if-else if-else if-…-else Let’s imagine a sausage! The sausage will represent all the values.

Page 89: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Multiple if-else if-else if-…-else Let’s imagine a sausage! The sausage will represent all the values.

Page 90: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Multiple if-else if-else if-…-else Let’s imagine a sausage! The sausage will represent all the values.

Page 91: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Multiple if-else if-else if-…-else Let’s imagine a sausage! The sausage will represent all the values.

Page 92: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Multiple if-else if-else if-…-else Let’s imagine a sausage! The sausage will represent all the values.

Page 93: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Multiple if-else if-else if-…-else Let’s imagine a sausage! The sausage will represent all the values.

Page 94: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Review exercise

Page 95: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Fighting exercise Write a program with which you

can simulate one round of fight between you and a monster.

First we read in the attributes of each of you.

Then we play one round of the fight.

Peter Tikos

Page 96: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Fighting rulesAttributes:

Attack Points (AP) Defense Points (DP) Damage (D) Life Points (LP)

Fight (one round): Attacker is chosen randomly (coin toss) Attack Points + 2 Dice ? Enemy’s Defense Points

> : Attacker hits defender, so life points decreased by damage <= : Miss

Rules

Page 97: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Let’s fight! First let’s generate random numbers!

Page 98: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

Let’s fight! First let’s generate random numbers! Then we are ready to fight

Page 99: Introduction to Java programming - Java tutorial for beginners to teach Java basics in an easy and entertaining way

What’s next Choose one from many (switch) Repeat it! (the loops)

– While– Do-while– For

Controlling loops– Break– Continue

Multiple loops one inside the other

www.duckademy.com/course/java-programmingCheck out the course: