SlideShare a Scribd company logo
JAVA
TajendarArora
OBJECTIVES
 What is Java?
 Why Java?
 Java System overview and Types of programs in java
 JVM
 JDK
 Primitive Data types in java
 Expressions in java
 Control Statements
 Naming conventions
 Arrays
 For-each loop
 Type casting
 Build first basic java program
 Command Line Arguments
TajendarArora
JAVA
 Java is high level programming language
introduced by Sun Microsystems in June 1995.
 Java is an object oriented language built upon C
& C++, It derived its object oriented features
from C++.
 The Java language has undergone several
changes since JDK 1.0 (1996) and now JSE 7 is
latest.
*jdk- Java Development Kit
*JSE- Java Standard Ediiton
TajendarArora
WHY JAVA
 Object-oriented
 Platform independent
 Built-in support for multi-threading, socket
communication and memory management
 Supports Web based applications (Applet,
Servlets and JSP)
 Vast library of predefined objects and operations
 Secure
TajendarArora
Tajendar Arora
JAVA FEATURES
 Simple and object oriented
 Look and feel of C
 Simplified object modeling
 Portability
 Java compiler generates byte codes
 Runtime systems for various platforms
 Size and behavior of basic data types defined
 Write once, run/debug anywhere
Tajendar Arora
JAVA FEATURES CONT.
 Availability
 Windows, Linux, Solaris,…
 Embedded systems
 Compiler and runtime are free
 Free IDEs: Eclipse, Netbeans
 Library
 Rich class library
 Part of the definition
 Standard GUI toolkit
Tajendar Arora
JAVA FEATURES CONT.
 Built-in model for concurrency
 Threads at the language level
 Synchronization
 Safety
 No Pointer!
 Automatic memory management – GC
 Networking
 Web Enabled
Tajendar Arora
JAVA SYSTEM OVERVIEW
APPLETS , SERVLETS AND APPLICATION
 An applet is designed to be embedded in a Web
page, and run by a browser.
 A servlet is designed to be run by a web server
which act as controller for we application.
 An application is a conventional standalone
program.
TajendarArora
Tajendar Arora
WHAT IS A VIRTUAL MACHINE?
 A virtual machine (VM) is an abstract computer
architecture
 Software on top of a real hardware
 Can run the same application on different
machines where the VM is available
Tajendar Arora
JVM CONT.
 Runtime environment for Java
 Implementation NOT defined
 Runs Java .class files
 Has to conform to Sun‘s specification
JDK DIRECTORY STRUCTURE
(JAVA INSTALLATIONS)
Assuming the JDK software is installed at /jdk1.7.0, here are
some of the most important directories:
/jdk1.7.0Root directory of the JDK software installation.
Contains copyright, license, and README files.
./jdk1.7.0/binExecutables for all the development tools
contained in the JDK. The PATH environment variable
should contain an entry for this directory.
/jdk1.7.0/lib Files used by the development tools.
Includes tools.jar, which contains non-core classes for support
of the tools and utilities in the JDK.
/jdk1.7.0/jre Root directory of the Java runtime environment
used by the JDK development tools. The runtime environment
is an implementation of the Java platform.
TajendarArora
PRIMITIVE DATA TYPES
 Main data types are int, double, boolean,
char
 Also have byte, short, long, float
 boolean has values true and false
 Variable Declarations look like,
 double x, y;
 int count = 0;
TajendarArora
EXPRESSIONS
 Assignment statements mostly look like those in
C; you can use =, +=, *= etc.
 Arithmetic uses the familiar + - * / %
 Java also has ++ and --
 Java has boolean operators && || !
 Java has comparisons < <= == != >= >
 Java does not have pointers or pointer arithmetic
TajendarArora
CONTROL STATEMENTS
•if (x < y) smaller = x;
•if (x < y){ smaller=x;sum += x;}
else { smaller = y; sum += y; }
•while (x < y) { y = y - x; }
•do { y = y - x; } while (x < y)
•for (int i = 0; i < max; i++) sum += i;
BUT: conditions must be boolean
TajendarArora
NAMING CONVENTIONS
Java is case-sensitive; maxval, maxVal, and
MaxVal are three different names Class names
begin with a capital letter All other names begin
with a lowercase letter Subsequent words are
capitalized: theBigOne Underscores are not used
in names,
These are very strong conventions.
TajendarArora
ARRAYS IN JAVA
 Java provides a data structure, the array, which
stores a fixed-size sequential collection of elements of
the same type. An array is used to store a collection of
data.
 Declare array
 dataType[] arrayRefVar; // preferred way.
 Creating Arrays:
 You can create an array by using the new operator
with the following syntax:
 arrayRefVar = new dataType[arraySize]; The above
statement does two things:
 It creates an array using new dataType[arraySize];
 It assigns the reference of the newly created array to
the variable arrayRefVar.
TajendarArora
FOR EACH LOOP FOR ARRAYS IN JAVA
 Since JDK 1.5 introduced a new for loop known
as foreach loop or enhanced for loop, which
enables you to traverse the complete array
sequentially without using an index variable.
 Example:
 The following code displays all the elements in
the array myList:
 public class TestArray {
 public static void main(String[] args) {
 double[] myList = {1.9, 2.9, 3.4, 3.5};
 // Print all the array elements
 for (double element: myList)
 { System.out.println(element);
 } } }
TajendarArora
TYPE CASTING IN JAVA
 Assigning a value of one type to a variable of
another type is known as Type Casting.
 In Java, type casting is classified into two types,
 Widening Casting(Implicit)
 Narrowing Casting(Explicitly done)

TajendarArora
TYPE CASTING IN JAVA
 Widening or Automatic type converion
 Automatic Type casting take place when,the two
types are compatible
 the target type is larger than the source type
 Example :
 int i = 100;
 long l = i;
 Narrowing or Explicit type conversion
 When you are assigning a larger type value to a
variable of smaller type, then you need to perform
explicit type casting.
 double d = 100.04;
 long l = (long)d;
 //explicit type casting required int i = (int)l;
TajendarArora
BUILDING STANDALONE JAVA PROGRAMS
 We can use different IDEs as well
 IDEs are more complex and have visual Java
development tools, tight integration with the
compiler or application server, and may include
tools for debugging, refactoring, version control,
and so forth. Some examples below
 Eclipse
 NetBeans
 BjueJ
 Jbuilder
TajendarArora
BUILDING STANDALONE JAVA PROGRAMS
 Prepare the file First.java using an editor
 /*
 This is a simple Java program.*/
 class First
 {
 public static void main(String args[])
 {
 System.out.println("This is a simple Java program.");
 }
 }
 Invoke the compiler: javac First.java
 This creates First.class
 Run the java interpreter: java First
 println is a member function for the System.out class
 String is built in class
* File name should be First.java
TajendarArora
COMMAND LINE ARGUMENTS
 A command-line argument is the information
that directly follows the program’s name on the
command line when it is executed. To access the
command-line arguments inside a Java program
is quite easy—they are stored as strings in the
String array passed to main( ).
 class CommandLine {
 public static void main(String args[]) {
 for(int i=0; i<args.length; i++)
 System.out.println("args[" + i + "]: " +args[i]);
 }
 }
 * length returns the length of array
TajendarArora
Thank you
TajendarArora
Ad

More Related Content

What's hot (20)

Java 101 intro to programming with java
Java 101  intro to programming with javaJava 101  intro to programming with java
Java 101 intro to programming with java
Hawkman Academy
 
Fundamentals of oop lecture 2
Fundamentals of oop lecture 2Fundamentals of oop lecture 2
Fundamentals of oop lecture 2
miiro30
 
Presentation on java
Presentation  on  javaPresentation  on  java
Presentation on java
shashi shekhar
 
Hibernate introduction
Hibernate introductionHibernate introduction
Hibernate introduction
Sagar Verma
 
Java basic
Java basicJava basic
Java basic
Arati Gadgil
 
1_JavIntro
1_JavIntro1_JavIntro
1_JavIntro
SARJERAO Sarju
 
Advance Java
Advance JavaAdvance Java
Advance Java
Vidyacenter
 
Core Java
Core JavaCore Java
Core Java
Prakash Dimmita
 
Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVA
KUNAL GADHIA
 
Java training in delhi
Java training in delhiJava training in delhi
Java training in delhi
APSMIND TECHNOLOGY PVT LTD.
 
Core java lessons
Core java lessonsCore java lessons
Core java lessons
vivek shah
 
Java &amp; advanced java
Java &amp; advanced javaJava &amp; advanced java
Java &amp; advanced java
BASAVARAJ HUNSHAL
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
Hitesh-Java
 
Basics of java programming language
Basics of java programming languageBasics of java programming language
Basics of java programming language
masud33bd
 
Basic java tutorial
Basic java tutorialBasic java tutorial
Basic java tutorial
Pedro De Almeida
 
Java basic-tutorial for beginners
Java basic-tutorial for beginners Java basic-tutorial for beginners
Java basic-tutorial for beginners
Muzammil Ali
 
Java Programming - 01 intro to java
Java Programming - 01 intro to javaJava Programming - 01 intro to java
Java Programming - 01 intro to java
Danairat Thanabodithammachari
 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in java
agorolabs
 
Core java1
Core java1Core java1
Core java1
Ravi varma
 
PROGRAMMING IN JAVA
PROGRAMMING IN JAVAPROGRAMMING IN JAVA
PROGRAMMING IN JAVA
SivaSankari36
 
Java 101 intro to programming with java
Java 101  intro to programming with javaJava 101  intro to programming with java
Java 101 intro to programming with java
Hawkman Academy
 
Fundamentals of oop lecture 2
Fundamentals of oop lecture 2Fundamentals of oop lecture 2
Fundamentals of oop lecture 2
miiro30
 
Hibernate introduction
Hibernate introductionHibernate introduction
Hibernate introduction
Sagar Verma
 
Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVA
KUNAL GADHIA
 
Core java lessons
Core java lessonsCore java lessons
Core java lessons
vivek shah
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
Hitesh-Java
 
Basics of java programming language
Basics of java programming languageBasics of java programming language
Basics of java programming language
masud33bd
 
Java basic-tutorial for beginners
Java basic-tutorial for beginners Java basic-tutorial for beginners
Java basic-tutorial for beginners
Muzammil Ali
 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in java
agorolabs
 

Viewers also liked (14)

Introduction to Jquery
Introduction to Jquery Introduction to Jquery
Introduction to Jquery
Tajendar Arora
 
Challenges confronting the police institution in ghana by evans kojo acheampong
Challenges confronting the police institution in ghana by evans kojo acheampongChallenges confronting the police institution in ghana by evans kojo acheampong
Challenges confronting the police institution in ghana by evans kojo acheampong
kojokay
 
Bus 402 week 5 discussion questions 1
Bus 402 week 5 discussion questions 1Bus 402 week 5 discussion questions 1
Bus 402 week 5 discussion questions 1
tiviwader1988
 
Formação Continuada
Formação ContinuadaFormação Continuada
Formação Continuada
Jakson Queiroz
 
11.measurement
11.measurement11.measurement
11.measurement
rags2richess
 
Tal Solutions Talent Science Presentation_FINAL3
Tal Solutions Talent Science Presentation_FINAL3Tal Solutions Talent Science Presentation_FINAL3
Tal Solutions Talent Science Presentation_FINAL3
Marcia Tal
 
The Power of Legacy
The Power of LegacyThe Power of Legacy
The Power of Legacy
Nancy L. Baumann
 
hospitality
hospitalityhospitality
hospitality
brendan newton
 
Bus 402 week 3 discussion questions 2
Bus 402 week 3 discussion questions 2Bus 402 week 3 discussion questions 2
Bus 402 week 3 discussion questions 2
goldfeschyrssmog1977
 
Einführung in die @4sqapi
Einführung in die @4sqapiEinführung in die @4sqapi
Einführung in die @4sqapi
Daniel Wiegand
 
CV CALUBAYAN LEAMOR L.
CV CALUBAYAN LEAMOR L.CV CALUBAYAN LEAMOR L.
CV CALUBAYAN LEAMOR L.
leamor calubayan
 
Unit 27 – task 2 coachs log
Unit 27 – task 2   coachs logUnit 27 – task 2   coachs log
Unit 27 – task 2 coachs log
taliaelisekaur
 
Global277 279
Global277 279Global277 279
Global277 279
brianhayward
 
Digital marketing-training-institute
Digital marketing-training-instituteDigital marketing-training-institute
Digital marketing-training-institute
softprostudent2
 
Introduction to Jquery
Introduction to Jquery Introduction to Jquery
Introduction to Jquery
Tajendar Arora
 
Challenges confronting the police institution in ghana by evans kojo acheampong
Challenges confronting the police institution in ghana by evans kojo acheampongChallenges confronting the police institution in ghana by evans kojo acheampong
Challenges confronting the police institution in ghana by evans kojo acheampong
kojokay
 
Bus 402 week 5 discussion questions 1
Bus 402 week 5 discussion questions 1Bus 402 week 5 discussion questions 1
Bus 402 week 5 discussion questions 1
tiviwader1988
 
Tal Solutions Talent Science Presentation_FINAL3
Tal Solutions Talent Science Presentation_FINAL3Tal Solutions Talent Science Presentation_FINAL3
Tal Solutions Talent Science Presentation_FINAL3
Marcia Tal
 
Bus 402 week 3 discussion questions 2
Bus 402 week 3 discussion questions 2Bus 402 week 3 discussion questions 2
Bus 402 week 3 discussion questions 2
goldfeschyrssmog1977
 
Einführung in die @4sqapi
Einführung in die @4sqapiEinführung in die @4sqapi
Einführung in die @4sqapi
Daniel Wiegand
 
Unit 27 – task 2 coachs log
Unit 27 – task 2   coachs logUnit 27 – task 2   coachs log
Unit 27 – task 2 coachs log
taliaelisekaur
 
Digital marketing-training-institute
Digital marketing-training-instituteDigital marketing-training-institute
Digital marketing-training-institute
softprostudent2
 
Ad

Similar to Introduction to java (20)

JAVA INETRNSHIP1 made with simple topics.ppt.pptx
JAVA INETRNSHIP1 made with simple topics.ppt.pptxJAVA INETRNSHIP1 made with simple topics.ppt.pptx
JAVA INETRNSHIP1 made with simple topics.ppt.pptx
fwzmypc2004
 
Object Oriented Programming unit 1 content for students
Object Oriented Programming unit 1 content for studentsObject Oriented Programming unit 1 content for students
Object Oriented Programming unit 1 content for students
ASHASITTeaching
 
Introduction to Core Java Programming
Introduction to Core Java ProgrammingIntroduction to Core Java Programming
Introduction to Core Java Programming
Collaboration Technologies
 
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
Nanthini Kempaiyan
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
Hamid Ghorbani
 
Java1
Java1Java1
Java1
computertuitions
 
Java
Java Java
Java
computertuitions
 
Core java introduction
Core java introductionCore java introduction
Core java introduction
Beenu Gautam
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruJava programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, Mysuru
Nithin Kumar,VVCE, Mysuru
 
Introduction
IntroductionIntroduction
Introduction
richsoden
 
Java platform
Java platformJava platform
Java platform
BG Java EE Course
 
2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud
vyshukodumuri
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptx
Murugesh33
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
Murugesh33
 
Java Developer Roadmap PDF By ScholarHat
Java Developer Roadmap PDF By ScholarHatJava Developer Roadmap PDF By ScholarHat
Java Developer Roadmap PDF By ScholarHat
Scholarhat
 
Java Programming Fundamentals: Complete Guide for Beginners
Java Programming Fundamentals: Complete Guide for BeginnersJava Programming Fundamentals: Complete Guide for Beginners
Java Programming Fundamentals: Complete Guide for Beginners
Taranath Jaishy
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
EduclentMegasoftel
 
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
AssignmentjsnsnshshusjdnsnshhzudjdndndjdAssignmentjsnsnshshusjdnsnshhzudjdndndjd
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
tusharjain613841
 
JAVA AND OOPS CONCEPTS.pptx helpful for engineering
JAVA AND OOPS CONCEPTS.pptx helpful for engineeringJAVA AND OOPS CONCEPTS.pptx helpful for engineering
JAVA AND OOPS CONCEPTS.pptx helpful for engineering
PriyanshuGupta101797
 
OOP-Chap2.docx
OOP-Chap2.docxOOP-Chap2.docx
OOP-Chap2.docx
NaorinHalim
 
JAVA INETRNSHIP1 made with simple topics.ppt.pptx
JAVA INETRNSHIP1 made with simple topics.ppt.pptxJAVA INETRNSHIP1 made with simple topics.ppt.pptx
JAVA INETRNSHIP1 made with simple topics.ppt.pptx
fwzmypc2004
 
Object Oriented Programming unit 1 content for students
Object Oriented Programming unit 1 content for studentsObject Oriented Programming unit 1 content for students
Object Oriented Programming unit 1 content for students
ASHASITTeaching
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
Hamid Ghorbani
 
Core java introduction
Core java introductionCore java introduction
Core java introduction
Beenu Gautam
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruJava programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, Mysuru
Nithin Kumar,VVCE, Mysuru
 
Introduction
IntroductionIntroduction
Introduction
richsoden
 
2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud
vyshukodumuri
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptx
Murugesh33
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
Murugesh33
 
Java Developer Roadmap PDF By ScholarHat
Java Developer Roadmap PDF By ScholarHatJava Developer Roadmap PDF By ScholarHat
Java Developer Roadmap PDF By ScholarHat
Scholarhat
 
Java Programming Fundamentals: Complete Guide for Beginners
Java Programming Fundamentals: Complete Guide for BeginnersJava Programming Fundamentals: Complete Guide for Beginners
Java Programming Fundamentals: Complete Guide for Beginners
Taranath Jaishy
 
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
AssignmentjsnsnshshusjdnsnshhzudjdndndjdAssignmentjsnsnshshusjdnsnshhzudjdndndjd
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
tusharjain613841
 
JAVA AND OOPS CONCEPTS.pptx helpful for engineering
JAVA AND OOPS CONCEPTS.pptx helpful for engineeringJAVA AND OOPS CONCEPTS.pptx helpful for engineering
JAVA AND OOPS CONCEPTS.pptx helpful for engineering
PriyanshuGupta101797
 
Ad

Recently uploaded (20)

What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
Ajanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of HistoryAjanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of History
Virag Sontakke
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
Ajanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of HistoryAjanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of History
Virag Sontakke
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 

Introduction to java

  • 2. OBJECTIVES  What is Java?  Why Java?  Java System overview and Types of programs in java  JVM  JDK  Primitive Data types in java  Expressions in java  Control Statements  Naming conventions  Arrays  For-each loop  Type casting  Build first basic java program  Command Line Arguments TajendarArora
  • 3. JAVA  Java is high level programming language introduced by Sun Microsystems in June 1995.  Java is an object oriented language built upon C & C++, It derived its object oriented features from C++.  The Java language has undergone several changes since JDK 1.0 (1996) and now JSE 7 is latest. *jdk- Java Development Kit *JSE- Java Standard Ediiton TajendarArora
  • 4. WHY JAVA  Object-oriented  Platform independent  Built-in support for multi-threading, socket communication and memory management  Supports Web based applications (Applet, Servlets and JSP)  Vast library of predefined objects and operations  Secure TajendarArora
  • 5. Tajendar Arora JAVA FEATURES  Simple and object oriented  Look and feel of C  Simplified object modeling  Portability  Java compiler generates byte codes  Runtime systems for various platforms  Size and behavior of basic data types defined  Write once, run/debug anywhere
  • 6. Tajendar Arora JAVA FEATURES CONT.  Availability  Windows, Linux, Solaris,…  Embedded systems  Compiler and runtime are free  Free IDEs: Eclipse, Netbeans  Library  Rich class library  Part of the definition  Standard GUI toolkit
  • 7. Tajendar Arora JAVA FEATURES CONT.  Built-in model for concurrency  Threads at the language level  Synchronization  Safety  No Pointer!  Automatic memory management – GC  Networking  Web Enabled
  • 9. APPLETS , SERVLETS AND APPLICATION  An applet is designed to be embedded in a Web page, and run by a browser.  A servlet is designed to be run by a web server which act as controller for we application.  An application is a conventional standalone program. TajendarArora
  • 10. Tajendar Arora WHAT IS A VIRTUAL MACHINE?  A virtual machine (VM) is an abstract computer architecture  Software on top of a real hardware  Can run the same application on different machines where the VM is available
  • 11. Tajendar Arora JVM CONT.  Runtime environment for Java  Implementation NOT defined  Runs Java .class files  Has to conform to Sun‘s specification
  • 12. JDK DIRECTORY STRUCTURE (JAVA INSTALLATIONS) Assuming the JDK software is installed at /jdk1.7.0, here are some of the most important directories: /jdk1.7.0Root directory of the JDK software installation. Contains copyright, license, and README files. ./jdk1.7.0/binExecutables for all the development tools contained in the JDK. The PATH environment variable should contain an entry for this directory. /jdk1.7.0/lib Files used by the development tools. Includes tools.jar, which contains non-core classes for support of the tools and utilities in the JDK. /jdk1.7.0/jre Root directory of the Java runtime environment used by the JDK development tools. The runtime environment is an implementation of the Java platform. TajendarArora
  • 13. PRIMITIVE DATA TYPES  Main data types are int, double, boolean, char  Also have byte, short, long, float  boolean has values true and false  Variable Declarations look like,  double x, y;  int count = 0; TajendarArora
  • 14. EXPRESSIONS  Assignment statements mostly look like those in C; you can use =, +=, *= etc.  Arithmetic uses the familiar + - * / %  Java also has ++ and --  Java has boolean operators && || !  Java has comparisons < <= == != >= >  Java does not have pointers or pointer arithmetic TajendarArora
  • 15. CONTROL STATEMENTS •if (x < y) smaller = x; •if (x < y){ smaller=x;sum += x;} else { smaller = y; sum += y; } •while (x < y) { y = y - x; } •do { y = y - x; } while (x < y) •for (int i = 0; i < max; i++) sum += i; BUT: conditions must be boolean TajendarArora
  • 16. NAMING CONVENTIONS Java is case-sensitive; maxval, maxVal, and MaxVal are three different names Class names begin with a capital letter All other names begin with a lowercase letter Subsequent words are capitalized: theBigOne Underscores are not used in names, These are very strong conventions. TajendarArora
  • 17. ARRAYS IN JAVA  Java provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data.  Declare array  dataType[] arrayRefVar; // preferred way.  Creating Arrays:  You can create an array by using the new operator with the following syntax:  arrayRefVar = new dataType[arraySize]; The above statement does two things:  It creates an array using new dataType[arraySize];  It assigns the reference of the newly created array to the variable arrayRefVar. TajendarArora
  • 18. FOR EACH LOOP FOR ARRAYS IN JAVA  Since JDK 1.5 introduced a new for loop known as foreach loop or enhanced for loop, which enables you to traverse the complete array sequentially without using an index variable.  Example:  The following code displays all the elements in the array myList:  public class TestArray {  public static void main(String[] args) {  double[] myList = {1.9, 2.9, 3.4, 3.5};  // Print all the array elements  for (double element: myList)  { System.out.println(element);  } } } TajendarArora
  • 19. TYPE CASTING IN JAVA  Assigning a value of one type to a variable of another type is known as Type Casting.  In Java, type casting is classified into two types,  Widening Casting(Implicit)  Narrowing Casting(Explicitly done)  TajendarArora
  • 20. TYPE CASTING IN JAVA  Widening or Automatic type converion  Automatic Type casting take place when,the two types are compatible  the target type is larger than the source type  Example :  int i = 100;  long l = i;  Narrowing or Explicit type conversion  When you are assigning a larger type value to a variable of smaller type, then you need to perform explicit type casting.  double d = 100.04;  long l = (long)d;  //explicit type casting required int i = (int)l; TajendarArora
  • 21. BUILDING STANDALONE JAVA PROGRAMS  We can use different IDEs as well  IDEs are more complex and have visual Java development tools, tight integration with the compiler or application server, and may include tools for debugging, refactoring, version control, and so forth. Some examples below  Eclipse  NetBeans  BjueJ  Jbuilder TajendarArora
  • 22. BUILDING STANDALONE JAVA PROGRAMS  Prepare the file First.java using an editor  /*  This is a simple Java program.*/  class First  {  public static void main(String args[])  {  System.out.println("This is a simple Java program.");  }  }  Invoke the compiler: javac First.java  This creates First.class  Run the java interpreter: java First  println is a member function for the System.out class  String is built in class * File name should be First.java TajendarArora
  • 23. COMMAND LINE ARGUMENTS  A command-line argument is the information that directly follows the program’s name on the command line when it is executed. To access the command-line arguments inside a Java program is quite easy—they are stored as strings in the String array passed to main( ).  class CommandLine {  public static void main(String args[]) {  for(int i=0; i<args.length; i++)  System.out.println("args[" + i + "]: " +args[i]);  }  }  * length returns the length of array TajendarArora
  翻译: