introduction to java 1 - hesamkorki.com · history of java • 1990 : the idea generated by patrick...

12
INTRODUCTION TO JAVA Hesam Korki Presents

Upload: others

Post on 01-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to JAVA 1 - hesamkorki.com · HISTORY OF JAVA • 1990 : The idea generated by Patrick Naughton — an engineer of Sun Microsystems • 1992 : The first official presentation

INTRODUCTION TO JAVA

Hesam Korki Presents

Page 2: Introduction to JAVA 1 - hesamkorki.com · HISTORY OF JAVA • 1990 : The idea generated by Patrick Naughton — an engineer of Sun Microsystems • 1992 : The first official presentation

HISTORY OF JAVA

• 1990 : The idea generated by Patrick Naughton — an engineer of Sun Microsystems

• 1992 : The first official presentation of the language called Oak language

• 1994 : Changing the name to Java Programming Language

• 1995 : Public release of Java1.0a

• 1996 : JDK1 1998 : J2SE 1.2 (aka Java2) 2000 : J2SE 1.3

• 2006 : Java SE6

• 2011 : Java SE7

• 2017 : JDK 9

Page 3: Introduction to JAVA 1 - hesamkorki.com · HISTORY OF JAVA • 1990 : The idea generated by Patrick Naughton — an engineer of Sun Microsystems • 1992 : The first official presentation

JAVA APPLICATIONS

Page 4: Introduction to JAVA 1 - hesamkorki.com · HISTORY OF JAVA • 1990 : The idea generated by Patrick Naughton — an engineer of Sun Microsystems • 1992 : The first official presentation

• Java Syntax is defined in the Java language specifications

• Java Library is defined in the Java API — Application Program Interface

• JDK is the software for developing and running Java

• IDE is an integrated development environment for developing programs rapidly and readily

• Java SE stands for standard edition for client-side applications

• Java EE stands for enterprise edition for server-side applications

• Java ME stands for micro edition for mobile applications

• JDK is a toolkit which comes with every JSE version — Java Development Toolkit which contains JVM, JRE and APIs

DEFINITIONS

Page 5: Introduction to JAVA 1 - hesamkorki.com · HISTORY OF JAVA • 1990 : The idea generated by Patrick Naughton — an engineer of Sun Microsystems • 1992 : The first official presentation

PROCESS CHART

Page 6: Introduction to JAVA 1 - hesamkorki.com · HISTORY OF JAVA • 1990 : The idea generated by Patrick Naughton — an engineer of Sun Microsystems • 1992 : The first official presentation

ESSENTIALS• You can easily write a Java program with any text editor and compile it as

long as you have installed JDK on your machine

• You should type the postposition of .java at the end of the text name — e.g A.java

• You can even write a plain text file using command prompt to run java apps — for Unix based systems: vi, and for windows edit

• Then you should type javac A.java to compile your file and get an A.class file, and in the end type java A to execute your program

• THE JAVA FILE NAME SHOULD MATCH THE CLASS NAME

• You’re probably wondering what is a class ? — are you familiar with the constructs in C and C++ ?

• The Java motto is: everything is an object

Page 7: Introduction to JAVA 1 - hesamkorki.com · HISTORY OF JAVA • 1990 : The idea generated by Patrick Naughton — an engineer of Sun Microsystems • 1992 : The first official presentation

IN JAVA

WRITING YOUR FIRST PROGRAM

• First, create a file and name it Hello.java, and start text editing it

• Now, what do you think should be the name of the class?

• public class Hello { // now we would define the main method public static void main(String[] args) { System.out.println(“ Hello World ”); } }

• Save and open your command prompt; go to the same directory which your java file is and type: javac Hello.java

• Open the directory and you should be able to detect Hello.class file; then again in terminal type: java Hello

Page 8: Introduction to JAVA 1 - hesamkorki.com · HISTORY OF JAVA • 1990 : The idea generated by Patrick Naughton — an engineer of Sun Microsystems • 1992 : The first official presentation

• Remember that java is case sensitive; so, from now on we would always write String not string

• Only can you have one public class in each java file but other classes are acceptable — to be told completely in the object oriented subject

• Now, write another program and name it Calculate then try to find the answer to the equation bellow with it:

• Importing libraries can help us using prewritten classes and methods like include in C

• Error popup message: import javax.swing.*; JOptionPane.showMessageDialog(null, “an error occurred”);

Page 9: Introduction to JAVA 1 - hesamkorki.com · HISTORY OF JAVA • 1990 : The idea generated by Patrick Naughton — an engineer of Sun Microsystems • 1992 : The first official presentation

PRIMITIVE TYPES

Page 10: Introduction to JAVA 1 - hesamkorki.com · HISTORY OF JAVA • 1990 : The idea generated by Patrick Naughton — an engineer of Sun Microsystems • 1992 : The first official presentation

Write a program that calculates the area of a circle with radius of 10

Page 11: Introduction to JAVA 1 - hesamkorki.com · HISTORY OF JAVA • 1990 : The idea generated by Patrick Naughton — an engineer of Sun Microsystems • 1992 : The first official presentation

IN JAVA

READING INPUT FROM THE CONSOLE

• We can use Scanner for reading inputs from the console

• It is in the java.util library; therefore, what should we do?

• Scanner input = new Scanner(System.in);

Page 12: Introduction to JAVA 1 - hesamkorki.com · HISTORY OF JAVA • 1990 : The idea generated by Patrick Naughton — an engineer of Sun Microsystems • 1992 : The first official presentation

Write a program that would calculate area and circumference of a circle with arbitrary radius which the user enters