SlideShare a Scribd company logo
Introduction TO JAVA
Rishi Ram Khanal
BIM(TU)
History of Java
Java was developed by James Gosling at Sun
Microsoftsystem and it was originated at Sun
Microsystem in 1991
JAVA is Everywhere
Java resides in mobiles,client machines,sever
machine,embedded device,smart phones,
cloud etc.
It shares the same basic features of the
language and libraries
Principle of java:write once,Run
anywhere(WORA)
What is Library?
Java Library is a collection of predefined
classes.
You can use these classes either by inheriting
them or by instantiating them.
JAVA flavours
Java se(core java)
Java EE (Advance java)
Java ME(Mobile Edition for java)
Version History Of JAVA
Version NO of classes NO of package
Java 1.0 212 8
Java 1.1 503 23
Java 2 1520 29
Java 5 3562 166
Java 6 3792 203
Java 7 4024 209
Features of JAVA
Simple
Object oriented Language
Distributed
Interpreted
Robust
Secure
Portable
Multi-threaded
Garbage Collector
Installation of Java
How to Compile?
Hello.java Hello.class
How to Run
Hello.class
OS
Interpreter(just-in-time compiler)
Installation and setup
• http://www.oracle.com/technetwork/java/javase
/downloads/jdk8-downloads-2133151.html
• After installation we will see a java folder where u
install the java.Inside java folder we will see two
folder
• Jdk: java development Kit used for to write java
program
• Jre:Java Runtime Enviroment used for to run the
java files
JDK and JRE
Java Development Kit contains tools needed
to develop the java programs
These tools could be
compiler(javac.exe),Application
Launcher(java.exe) etc
Jre: Java Runtime Environment
It contains JVM(java Virtual Machine) and java
Package classes(java Library)
JVM
JVM is platform dependent
The java Virtual Machine provides a platform
–independent way of executing code
Java Virtual Machine Interprets the bytecode
Into machine code depending upon the
underlying operating system and hardware
combination
First Program JAVA
Remember
• Java is a case sensitive language like c and c++
• Java is nearly 100% object oriented language
• In java, it is possible to make a function which
is not a member of any class(as we can do in c
and C++)
First Program
Public class HelloWorld
{
public static void main(String args[])
{
System.out.println(“HelloWOrld”);
}
}
FOR pratical
• Write a program in notepad and save in bin
folder of jdk Compile and run the program
Delete the file from bin folder and make another
program in notepad and save in Desktop and
compile and run the program and please note
the error u got and how u solve the error
DataTypes and Keywords In java
 Java Identifiers
All the java components require names.Names used for
classes, variables and method are called identifiers.In java ,
there are several points to remember about identifiers.
• All identifiers should begin with a letter (A to Z or a to z),
currency character ($) or an underscore (_).
• After the first character, identifiers can have any combination
of characters.
• A keyword cannot be used as an identifier.
• Most importantly identifiers are case sensitive.
• Examples of legal identifiers:age, $salary, _value, __1_value
• Examples of illegal identifiers: 123abc, -salary
Java Keywords
• These reserved words may not be used as constant or variable or any other identifier
names.
WhiteSpace
Literals, Comments,Separators
Literals
A literal is a source code representation of a fixed value. They are
represented directly in the code without any computation.
Comments
Java supports single-line and multi-line comments very similar to c and
c++. All characters available inside any comment are ignored by Java
compiler.
/* This is my first java program.
This will print 'Hello World' as the output
This is an example of multi-line comments. */
// This is an example of single line comment /* This is also an example of
single line comment. */
Data Types in JAVA
Details about Literals
Literals can be assigned to any primitive type variable. For example:
byte a =68;
char a ='A'
byte, int, long, and short can be expressed in decimal(
base 10),hexadecimal(base 16) or octal(base 8) number systems as well.
Prefix 0 is used to indicate octal and prefix 0x indicates hexadecimal when
using these number systems for literals. For example:
int decimal=100;
int octal =0144;
int hexa =0x64;
String literals in Java are specified like they are in most other languages by
enclosing a sequence of characters between a pair of double quotes.
String and char types of literals can contain any Unicode characters. For
example:
char a ='u0001'; String a ="u0001";
Variable
• In Java, all variables must be declared before they
can be used. The basic form of a variable
declaration is shown here:
type identifier [= value][, identifier [= value]...];
int a, b, c;// declares three ints, a, b, and c.
int d =3, e, f =5;// declares three more ints,
initializing // d and f.
byte z =22;// initializes z.
double pi =3.14159;// declares an approximation of
pi.
char x ='x';// the variable x has the value 'x'.
• This chapter will explain various variable types
available in Java Language. There are three
kinds of variables in Java:
• Local variables
• Instance variables
• Class/static variables
TYPECASTING in JAVA
Impicit Type Casting
Explicit Type Casting
SCANNER OBJECT
ARRAYS
ARRAY
• Declaring Array Variables:
To use an array in a program, you must declare a variable to
reference the array, and you must specify the type of array the variable
can reference. Here is the syntax for declaring an array variable:
dataType[] arrayRefVar; // preferred way.
or
dataType arrayRefVar[]; // works but not preferred way.
Example:
• The following code snippets are examples of this syntax:
double[] myList; // preferred way.
or
• double myList[]; // works but not preferred way.
Creating ARRAY
• 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.
• Declaring an array variable, creating an array, and assigning the reference
of the array to the variable can be combined in one statement, as shown
below:
• dataType[] arrayRefVar = new dataType[arraySize];
• Alternatively you can create arrays as follows:
• dataType[] arrayRefVar = {value0, value1, ..., valuek};
• The array elements are accessed through the index. Array indices are 0-
based; that is, they start from 0 to arrayRefVar.length-1.
• Following statement declares an array variable, myList,
creates an array of 10 elements of double type and assigns its
reference to myList:
• double[] myList = new double[10];
• Following picture represents array myList. Here, myList holds
ten double values and the indices are from 0 to 9.
The foreach Loops:
• 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.
• SCANNER OBJECT
PRACTICAL
• TypeCasting Problem
• Declare an array whose size is 5 .Process the
array and Print all the elements of array and
find total sum of all elements and Find
greatest number from that element
• Implement foreach Loop
• Create a class , take the two input from
keyboard and sum two number and process
the array by using Scanner

More Related Content

What's hot

Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented Programming
Ahmed Swilam
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
CPD INDIA
 
Python unit 3 m.sc cs
Python unit 3 m.sc csPython unit 3 m.sc cs
Python unit 3 m.sc cs
KALAISELVI P
 
CLASS & OBJECT IN JAVA
CLASS & OBJECT  IN JAVACLASS & OBJECT  IN JAVA
CLASS & OBJECT IN JAVA
Riaj Uddin Mahi
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
Sujith Kumar
 
Object Oriented Programming in PHP
Object Oriented Programming in PHPObject Oriented Programming in PHP
Object Oriented Programming in PHP
Lorna Mitchell
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with JavaJussi Pohjolainen
 
Object oreinted php | OOPs
Object oreinted php | OOPsObject oreinted php | OOPs
Object oreinted php | OOPs
Ravi Bhadauria
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
Tushar B Kute
 
Synapseindia object oriented programming in php
Synapseindia object oriented programming in phpSynapseindia object oriented programming in php
Synapseindia object oriented programming in php
Synapseindiappsdevelopment
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object References
Tareq Hasan
 
Lect 1-java object-classes
Lect 1-java object-classesLect 1-java object-classes
Lect 1-java object-classes
Fajar Baskoro
 
Python – Object Oriented Programming
Python – Object Oriented Programming Python – Object Oriented Programming
Python – Object Oriented Programming
Raghunath A
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
Praveen M Jigajinni
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
DevaKumari Vijay
 
Computer Programming 2
Computer Programming 2 Computer Programming 2
Computer Programming 2
VasanthiMuniasamy2
 
Java cheat sheet
Java cheat sheet Java cheat sheet
Java cheat sheet
Saifur Rahman
 
Object oriented approach in python programming
Object oriented approach in python programmingObject oriented approach in python programming
Object oriented approach in python programming
Srinivas Narasegouda
 
Advanced php
Advanced phpAdvanced php
Advanced phphamfu
 
Unidad o informatica en ingles
Unidad o informatica en inglesUnidad o informatica en ingles
Unidad o informatica en ingles
Marisa Torrecillas
 

What's hot (20)

Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented Programming
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
 
Python unit 3 m.sc cs
Python unit 3 m.sc csPython unit 3 m.sc cs
Python unit 3 m.sc cs
 
CLASS & OBJECT IN JAVA
CLASS & OBJECT  IN JAVACLASS & OBJECT  IN JAVA
CLASS & OBJECT IN JAVA
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 
Object Oriented Programming in PHP
Object Oriented Programming in PHPObject Oriented Programming in PHP
Object Oriented Programming in PHP
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Object oreinted php | OOPs
Object oreinted php | OOPsObject oreinted php | OOPs
Object oreinted php | OOPs
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
 
Synapseindia object oriented programming in php
Synapseindia object oriented programming in phpSynapseindia object oriented programming in php
Synapseindia object oriented programming in php
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object References
 
Lect 1-java object-classes
Lect 1-java object-classesLect 1-java object-classes
Lect 1-java object-classes
 
Python – Object Oriented Programming
Python – Object Oriented Programming Python – Object Oriented Programming
Python – Object Oriented Programming
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
 
Computer Programming 2
Computer Programming 2 Computer Programming 2
Computer Programming 2
 
Java cheat sheet
Java cheat sheet Java cheat sheet
Java cheat sheet
 
Object oriented approach in python programming
Object oriented approach in python programmingObject oriented approach in python programming
Object oriented approach in python programming
 
Advanced php
Advanced phpAdvanced php
Advanced php
 
Unidad o informatica en ingles
Unidad o informatica en inglesUnidad o informatica en ingles
Unidad o informatica en ingles
 

Similar to Introduction to java

Hello Java-First Level
Hello Java-First LevelHello Java-First Level
Hello Java-First Level
Dr. Raaid Alubady
 
Hello java
Hello java   Hello java
Hello java
Hello java  Hello java
Chapter 2 java
Chapter 2 javaChapter 2 java
Chapter 2 java
Ahmad sohail Kakar
 
OOP-java-variables.pptx
OOP-java-variables.pptxOOP-java-variables.pptx
OOP-java-variables.pptx
ssuserb1a18d
 
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
AssignmentjsnsnshshusjdnsnshhzudjdndndjdAssignmentjsnsnshshusjdnsnshhzudjdndndjd
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
tusharjain613841
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
Jayfee Ramos
 
Let's start with Java- Basic Concepts
Let's start with Java- Basic ConceptsLet's start with Java- Basic Concepts
Let's start with Java- Basic Concepts
Aashish Jain
 
Java
JavaJava
intro_java (1).pptx
intro_java (1).pptxintro_java (1).pptx
intro_java (1).pptx
SmitNikumbh
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Tajendar Arora
 
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
 
COMPUTER PROGRAMMING LANGUAGE.pptx
COMPUTER PROGRAMMING LANGUAGE.pptxCOMPUTER PROGRAMMING LANGUAGE.pptx
COMPUTER PROGRAMMING LANGUAGE.pptx
SofiaArquero2
 
Std 12 Computer Chapter 7 Java Basics (Part 1)
Std 12 Computer Chapter 7 Java Basics (Part 1)Std 12 Computer Chapter 7 Java Basics (Part 1)
Std 12 Computer Chapter 7 Java Basics (Part 1)
Nuzhat Memon
 
Java ce241
Java ce241Java ce241
Java ce241
Minal Maniar
 
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_reviewEdureka!
 
Java basic concept
Java basic conceptJava basic concept
Java basic concept
University of Potsdam
 
Java programing language unit 1 introduction
Java programing language unit 1 introductionJava programing language unit 1 introduction
Java programing language unit 1 introduction
chnrketan
 

Similar to Introduction to java (20)

Hello Java-First Level
Hello Java-First LevelHello Java-First Level
Hello Java-First Level
 
Hello java
Hello java   Hello java
Hello java
 
Hello java
Hello java  Hello java
Hello java
 
Chapter 2 java
Chapter 2 javaChapter 2 java
Chapter 2 java
 
Java
JavaJava
Java
 
OOP-java-variables.pptx
OOP-java-variables.pptxOOP-java-variables.pptx
OOP-java-variables.pptx
 
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
AssignmentjsnsnshshusjdnsnshhzudjdndndjdAssignmentjsnsnshshusjdnsnshhzudjdndndjd
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Let's start with Java- Basic Concepts
Let's start with Java- Basic ConceptsLet's start with Java- Basic Concepts
Let's start with Java- Basic Concepts
 
Java
JavaJava
Java
 
intro_java (1).pptx
intro_java (1).pptxintro_java (1).pptx
intro_java (1).pptx
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
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
 
COMPUTER PROGRAMMING LANGUAGE.pptx
COMPUTER PROGRAMMING LANGUAGE.pptxCOMPUTER PROGRAMMING LANGUAGE.pptx
COMPUTER PROGRAMMING LANGUAGE.pptx
 
Std 12 Computer Chapter 7 Java Basics (Part 1)
Std 12 Computer Chapter 7 Java Basics (Part 1)Std 12 Computer Chapter 7 Java Basics (Part 1)
Std 12 Computer Chapter 7 Java Basics (Part 1)
 
Java ce241
Java ce241Java ce241
Java ce241
 
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_review
 
Java basic concept
Java basic conceptJava basic concept
Java basic concept
 
Java programing language unit 1 introduction
Java programing language unit 1 introductionJava programing language unit 1 introduction
Java programing language unit 1 introduction
 
Unit 1
Unit 1Unit 1
Unit 1
 

More from rishi ram khanal

Measurement of gdp under product method
Measurement of gdp under product methodMeasurement of gdp under product method
Measurement of gdp under product method
rishi ram khanal
 
Major social problem in nepal child labour socilology
Major social problem in nepal child labour socilologyMajor social problem in nepal child labour socilology
Major social problem in nepal child labour socilology
rishi ram khanal
 
Light source ooad
Light source ooadLight source ooad
Light source ooad
rishi ram khanal
 
Introduction to artificial intelligence
Introduction to artificial intelligenceIntroduction to artificial intelligence
Introduction to artificial intelligence
rishi ram khanal
 
Interview method in research
Interview method in researchInterview method in research
Interview method in research
rishi ram khanal
 
Presentation on kurtosis statistics
Presentation on kurtosis statisticsPresentation on kurtosis statistics
Presentation on kurtosis statistics
rishi ram khanal
 
Importance of double entry accounting system for public limited company (basi...
Importance of double entry accounting system for public limited company (basi...Importance of double entry accounting system for public limited company (basi...
Importance of double entry accounting system for public limited company (basi...
rishi ram khanal
 
Implementation issues software engineering
Implementation issues software engineeringImplementation issues software engineering
Implementation issues software engineering
rishi ram khanal
 
Effect of migration in developing country
Effect of migration in developing countryEffect of migration in developing country
Effect of migration in developing country
rishi ram khanal
 
GUI (graphical user interface)
GUI (graphical user interface)GUI (graphical user interface)
GUI (graphical user interface)
rishi ram khanal
 
Goals of firm business finance
Goals of firm business financeGoals of firm business finance
Goals of firm business finance
rishi ram khanal
 
General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)
rishi ram khanal
 
GDP and trends economics .rishi
GDP and trends economics .rishiGDP and trends economics .rishi
GDP and trends economics .rishi
rishi ram khanal
 
Final internship-report on the networking department of the internet service ...
Final internship-report on the networking department of the internet service ...Final internship-report on the networking department of the internet service ...
Final internship-report on the networking department of the internet service ...
rishi ram khanal
 
Field study of crystal finance share broker
Field study of crystal finance share brokerField study of crystal finance share broker
Field study of crystal finance share broker
rishi ram khanal
 
Dijkstra algorithm
Dijkstra algorithmDijkstra algorithm
Dijkstra algorithm
rishi ram khanal
 
Computer virus and worms
Computer virus and wormsComputer virus and worms
Computer virus and worms
rishi ram khanal
 
Database management system
Database management systemDatabase management system
Database management system
rishi ram khanal
 
Credential reuse cyber security
Credential reuse cyber securityCredential reuse cyber security
Credential reuse cyber security
rishi ram khanal
 
Cisco packet tracer router
Cisco packet tracer  routerCisco packet tracer  router
Cisco packet tracer router
rishi ram khanal
 

More from rishi ram khanal (20)

Measurement of gdp under product method
Measurement of gdp under product methodMeasurement of gdp under product method
Measurement of gdp under product method
 
Major social problem in nepal child labour socilology
Major social problem in nepal child labour socilologyMajor social problem in nepal child labour socilology
Major social problem in nepal child labour socilology
 
Light source ooad
Light source ooadLight source ooad
Light source ooad
 
Introduction to artificial intelligence
Introduction to artificial intelligenceIntroduction to artificial intelligence
Introduction to artificial intelligence
 
Interview method in research
Interview method in researchInterview method in research
Interview method in research
 
Presentation on kurtosis statistics
Presentation on kurtosis statisticsPresentation on kurtosis statistics
Presentation on kurtosis statistics
 
Importance of double entry accounting system for public limited company (basi...
Importance of double entry accounting system for public limited company (basi...Importance of double entry accounting system for public limited company (basi...
Importance of double entry accounting system for public limited company (basi...
 
Implementation issues software engineering
Implementation issues software engineeringImplementation issues software engineering
Implementation issues software engineering
 
Effect of migration in developing country
Effect of migration in developing countryEffect of migration in developing country
Effect of migration in developing country
 
GUI (graphical user interface)
GUI (graphical user interface)GUI (graphical user interface)
GUI (graphical user interface)
 
Goals of firm business finance
Goals of firm business financeGoals of firm business finance
Goals of firm business finance
 
General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)
 
GDP and trends economics .rishi
GDP and trends economics .rishiGDP and trends economics .rishi
GDP and trends economics .rishi
 
Final internship-report on the networking department of the internet service ...
Final internship-report on the networking department of the internet service ...Final internship-report on the networking department of the internet service ...
Final internship-report on the networking department of the internet service ...
 
Field study of crystal finance share broker
Field study of crystal finance share brokerField study of crystal finance share broker
Field study of crystal finance share broker
 
Dijkstra algorithm
Dijkstra algorithmDijkstra algorithm
Dijkstra algorithm
 
Computer virus and worms
Computer virus and wormsComputer virus and worms
Computer virus and worms
 
Database management system
Database management systemDatabase management system
Database management system
 
Credential reuse cyber security
Credential reuse cyber securityCredential reuse cyber security
Credential reuse cyber security
 
Cisco packet tracer router
Cisco packet tracer  routerCisco packet tracer  router
Cisco packet tracer router
 

Recently uploaded

Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 

Recently uploaded (20)

Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 

Introduction to java

  • 1. Introduction TO JAVA Rishi Ram Khanal BIM(TU)
  • 2. History of Java Java was developed by James Gosling at Sun Microsoftsystem and it was originated at Sun Microsystem in 1991
  • 3. JAVA is Everywhere Java resides in mobiles,client machines,sever machine,embedded device,smart phones, cloud etc. It shares the same basic features of the language and libraries Principle of java:write once,Run anywhere(WORA)
  • 4. What is Library? Java Library is a collection of predefined classes. You can use these classes either by inheriting them or by instantiating them. JAVA flavours Java se(core java) Java EE (Advance java) Java ME(Mobile Edition for java)
  • 5. Version History Of JAVA Version NO of classes NO of package Java 1.0 212 8 Java 1.1 503 23 Java 2 1520 29 Java 5 3562 166 Java 6 3792 203 Java 7 4024 209
  • 6. Features of JAVA Simple Object oriented Language Distributed Interpreted Robust Secure Portable Multi-threaded Garbage Collector
  • 7. Installation of Java How to Compile? Hello.java Hello.class How to Run Hello.class OS Interpreter(just-in-time compiler)
  • 8. Installation and setup • http://www.oracle.com/technetwork/java/javase /downloads/jdk8-downloads-2133151.html • After installation we will see a java folder where u install the java.Inside java folder we will see two folder • Jdk: java development Kit used for to write java program • Jre:Java Runtime Enviroment used for to run the java files
  • 9. JDK and JRE Java Development Kit contains tools needed to develop the java programs These tools could be compiler(javac.exe),Application Launcher(java.exe) etc Jre: Java Runtime Environment It contains JVM(java Virtual Machine) and java Package classes(java Library)
  • 10. JVM JVM is platform dependent The java Virtual Machine provides a platform –independent way of executing code Java Virtual Machine Interprets the bytecode Into machine code depending upon the underlying operating system and hardware combination
  • 11. First Program JAVA Remember • Java is a case sensitive language like c and c++ • Java is nearly 100% object oriented language • In java, it is possible to make a function which is not a member of any class(as we can do in c and C++)
  • 12. First Program Public class HelloWorld { public static void main(String args[]) { System.out.println(“HelloWOrld”); } }
  • 13. FOR pratical • Write a program in notepad and save in bin folder of jdk Compile and run the program Delete the file from bin folder and make another program in notepad and save in Desktop and compile and run the program and please note the error u got and how u solve the error
  • 14. DataTypes and Keywords In java  Java Identifiers All the java components require names.Names used for classes, variables and method are called identifiers.In java , there are several points to remember about identifiers. • All identifiers should begin with a letter (A to Z or a to z), currency character ($) or an underscore (_). • After the first character, identifiers can have any combination of characters. • A keyword cannot be used as an identifier. • Most importantly identifiers are case sensitive. • Examples of legal identifiers:age, $salary, _value, __1_value • Examples of illegal identifiers: 123abc, -salary
  • 15. Java Keywords • These reserved words may not be used as constant or variable or any other identifier names.
  • 17. Literals, Comments,Separators Literals A literal is a source code representation of a fixed value. They are represented directly in the code without any computation. Comments Java supports single-line and multi-line comments very similar to c and c++. All characters available inside any comment are ignored by Java compiler. /* This is my first java program. This will print 'Hello World' as the output This is an example of multi-line comments. */ // This is an example of single line comment /* This is also an example of single line comment. */
  • 19.
  • 20. Details about Literals Literals can be assigned to any primitive type variable. For example: byte a =68; char a ='A' byte, int, long, and short can be expressed in decimal( base 10),hexadecimal(base 16) or octal(base 8) number systems as well. Prefix 0 is used to indicate octal and prefix 0x indicates hexadecimal when using these number systems for literals. For example: int decimal=100; int octal =0144; int hexa =0x64; String literals in Java are specified like they are in most other languages by enclosing a sequence of characters between a pair of double quotes. String and char types of literals can contain any Unicode characters. For example: char a ='u0001'; String a ="u0001";
  • 21. Variable • In Java, all variables must be declared before they can be used. The basic form of a variable declaration is shown here: type identifier [= value][, identifier [= value]...]; int a, b, c;// declares three ints, a, b, and c. int d =3, e, f =5;// declares three more ints, initializing // d and f. byte z =22;// initializes z. double pi =3.14159;// declares an approximation of pi. char x ='x';// the variable x has the value 'x'.
  • 22. • This chapter will explain various variable types available in Java Language. There are three kinds of variables in Java: • Local variables • Instance variables • Class/static variables
  • 23. TYPECASTING in JAVA Impicit Type Casting Explicit Type Casting SCANNER OBJECT ARRAYS
  • 24. ARRAY • Declaring Array Variables: To use an array in a program, you must declare a variable to reference the array, and you must specify the type of array the variable can reference. Here is the syntax for declaring an array variable: dataType[] arrayRefVar; // preferred way. or dataType arrayRefVar[]; // works but not preferred way. Example: • The following code snippets are examples of this syntax: double[] myList; // preferred way. or • double myList[]; // works but not preferred way.
  • 25. Creating ARRAY • 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. • Declaring an array variable, creating an array, and assigning the reference of the array to the variable can be combined in one statement, as shown below: • dataType[] arrayRefVar = new dataType[arraySize]; • Alternatively you can create arrays as follows: • dataType[] arrayRefVar = {value0, value1, ..., valuek}; • The array elements are accessed through the index. Array indices are 0- based; that is, they start from 0 to arrayRefVar.length-1.
  • 26. • Following statement declares an array variable, myList, creates an array of 10 elements of double type and assigns its reference to myList: • double[] myList = new double[10]; • Following picture represents array myList. Here, myList holds ten double values and the indices are from 0 to 9.
  • 27. The foreach Loops: • 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. • SCANNER OBJECT
  • 28. PRACTICAL • TypeCasting Problem • Declare an array whose size is 5 .Process the array and Print all the elements of array and find total sum of all elements and Find greatest number from that element • Implement foreach Loop • Create a class , take the two input from keyboard and sum two number and process the array by using Scanner