SlideShare a Scribd company logo
Introduction to Java
www.proximo.com
Introduction
Present the syntax of Java
Introduce the Java API
Demonstrate how to build
◦ stand-alone Java programs
◦ Java applets, which run within browsers e.g. Netscape
Example programs
Why Java?
It’s the current “hot” language
It’s almost entirely object-oriented
It has a vast library of predefined objects and operations
It’s more platform independent
◦ this makes it great for Web programming
It’s more secure
It isn’t C++
Applets, Servlets and Applications
An applet is designed to be embedded in a Web page, and run by a browser
Applets run in a sandbox with numerous restrictions; for example, they can’t
read files and then use the network
A servlet is designed to be run by a web server
An application is a conventional program
Building Standalone JAVA Programs
(on UNIX)
Prepare the file foo.java using an editor
Invoke the compiler: javac foo.java
This creates foo.class
Run the java interpreter: java foo
Java Virtual Machine
The .class files generated by the compiler are not executable binaries
◦ so Java combines compilation and interpretation
Instead, they contain “byte-codes” to be executed by the Java Virtual Machine
◦ other languages have done this, e.g. UCSD Pascal
This approach provides platform independence, and greater security
HelloWorld (standalone)
Note that String is built in
println is a member function for the System.out class
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Comments are almost like C++
/* This kind of comment can span multiple lines */
// This kind is to the end of the line
/**
* This kind of comment is a special
* ‘javadoc’ style comment
*/
Primitive data types are like C
Main data types are int, double, boolean, char
Also have byte, short, long, float
boolean has values true and false
Declarations look like C, for example,
◦ double x, y;
◦ int count = 0;
Expressions are like C
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
Control statements are like C
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 !
Control statements II
Java also introduces the try statement, about which more later
switch (n + 1) {
case 0: m = n - 1; break;
case 1: m = n + 1;
case 3: m = m * n; break;
default: m = -n; break;
}
Java isn't C!
In C, almost everything is in functions
In Java, almost everything is in classes
There is often only one class per file
There must be only one public class per file
The file name must be the same as the name of that public class, but with a
.java extension
Java program layout
A typical Java file looks like:
import java.awt.*;
import java.util.*;
public class SomethingOrOther {
// object definitions go here
. . .
}
This must be in a file named SomethingOrOther.java !
What is a class?
Early languages had only arrays
◦ all elements had to be of the same type
Then languages introduced structures (called records, or structs)
◦ allowed different data types to be grouped
Then Abstract Data Types (ADTs) became popular
◦ grouped operations along with the data
So, what is a class?
A class consists of
◦ a collection of fields, or variables, very much like the named fields of a struct
◦ all the operations (called methods) that can be performed on those fields
◦ can be instantiated
A class describes objects and operations defined on those objects
Name 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!
The class hierarchy
Classes are arranged in a hierarchy
The root, or topmost, class is Object
Every class but Object has at least one superclass
A class may have subclasses
Each class inherits all the fields and methods of its (possibly numerous)
superclasses
An example of a class
class Person {
String name;
int age;
void birthday ( ) {
age++;
System.out.println (name + ' is now '
+ age);
}
}
Another example of a class
class Driver extends Person {
long driversLicenseNumber;
Date expirationDate;
}
Creating and using an object
Person john;
john = new Person ( );
john.name = "John Smith";
john.age = 37;
Person mary = new Person ( );
mary.name = "Mary Brown";
mary.age = 33;
mary.birthday ( );
An array is an object
Person mary = new Person ( );
int myArray[ ] = new int[5];
◦ or:
int myArray[ ] = {1, 4, 9, 16, 25};
String languages [ ] = {"Prolog", "Java"};
www.proximo.in
Address: No:3, II Floor, 100 ft Road,
BTM Layout, II Stage, Bangalore,
Karnataka (560 076) India
Tel: +91 (0)80 4900 1234
Mail: info@proximo.in
CONTACT US
Thanks for watching

More Related Content

What's hot

Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
atozknowledge .com
 
Java
JavaJava
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
Ravi Kant Sahu
 
Java
JavaJava
Java
s4al_com
 
Core Java
Core JavaCore Java
Core Java
NA
 
Genesis and Overview of Java
Genesis and Overview of Java Genesis and Overview of Java
Genesis and Overview of Java
Ravi_Kant_Sahu
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
Professional Guru
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
jyoti_lakhani
 
OOP java
OOP javaOOP java
OOP java
xball977
 
Java Basics
Java BasicsJava Basics
Java Basics
Sunil OS
 
Introduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita GanesanIntroduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita Ganesan
Kavita Ganesan
 
Java Programming
Java ProgrammingJava Programming
Java Programming
Elizabeth alexander
 
Basic of Java
Basic of JavaBasic of Java
Basic of Java
Ajeet Kumar Verma
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
Abir Mohammad
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
Java Lover
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
Java
JavaJava
Introduction to Java -unit-1
Introduction to Java -unit-1Introduction to Java -unit-1
Introduction to Java -unit-1
RubaNagarajan
 
Introduction to Java Programming
Introduction to Java Programming Introduction to Java Programming
Introduction to Java Programming
Saravanakumar R
 
Oops in java
Oops in javaOops in java

What's hot (20)

Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
 
Java
JavaJava
Java
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Java
JavaJava
Java
 
Core Java
Core JavaCore Java
Core Java
 
Genesis and Overview of Java
Genesis and Overview of Java Genesis and Overview of Java
Genesis and Overview of Java
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
OOP java
OOP javaOOP java
OOP java
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Introduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita GanesanIntroduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita Ganesan
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Basic of Java
Basic of JavaBasic of Java
Basic of Java
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
 
Java
JavaJava
Java
 
Introduction to Java -unit-1
Introduction to Java -unit-1Introduction to Java -unit-1
Introduction to Java -unit-1
 
Introduction to Java Programming
Introduction to Java Programming Introduction to Java Programming
Introduction to Java Programming
 
Oops in java
Oops in javaOops in java
Oops in java
 

Viewers also liked

Deidre CV October 2015 (1)
Deidre CV October 2015 (1)Deidre CV October 2015 (1)
Deidre CV October 2015 (1)
Deidre-Ann Burger
 
CV Sophio Kobakhidze_2015
CV Sophio Kobakhidze_2015CV Sophio Kobakhidze_2015
CV Sophio Kobakhidze_2015
Sophio Kobakhidze
 
Resume
ResumeResume
Old navy sales associate perfomance appraisal 2
Old navy sales associate perfomance appraisal 2Old navy sales associate perfomance appraisal 2
Old navy sales associate perfomance appraisal 2
tonychoper4304
 
2.26.2014_Northern VA Realtor_Korean Forum 5
2.26.2014_Northern VA Realtor_Korean Forum 52.26.2014_Northern VA Realtor_Korean Forum 5
2.26.2014_Northern VA Realtor_Korean Forum 5
Hyojung Garland
 
Executive summary slide
Executive summary slideExecutive summary slide
Executive summary slide
ericaball19
 
World War
World WarWorld War
World War
bennyboi11
 
Proximo Tech Soft
Proximo Tech SoftProximo Tech Soft
Proximo Tech Soft
proximotechsoft
 
Resume SKP
Resume SKPResume SKP
Resume SKP
Shivaraj Kumar.P
 
CATÁLOGO INZEIN
CATÁLOGO INZEINCATÁLOGO INZEIN
CATÁLOGO INZEIN
Pedro Navarro Muñoz
 
Proximo
ProximoProximo
Aprendendo a programar - Programação Procedural vs OOP
Aprendendo a programar - Programação Procedural vs OOPAprendendo a programar - Programação Procedural vs OOP
Aprendendo a programar - Programação Procedural vs OOP
Leonardo Bastos
 

Viewers also liked (12)

Deidre CV October 2015 (1)
Deidre CV October 2015 (1)Deidre CV October 2015 (1)
Deidre CV October 2015 (1)
 
CV Sophio Kobakhidze_2015
CV Sophio Kobakhidze_2015CV Sophio Kobakhidze_2015
CV Sophio Kobakhidze_2015
 
Resume
ResumeResume
Resume
 
Old navy sales associate perfomance appraisal 2
Old navy sales associate perfomance appraisal 2Old navy sales associate perfomance appraisal 2
Old navy sales associate perfomance appraisal 2
 
2.26.2014_Northern VA Realtor_Korean Forum 5
2.26.2014_Northern VA Realtor_Korean Forum 52.26.2014_Northern VA Realtor_Korean Forum 5
2.26.2014_Northern VA Realtor_Korean Forum 5
 
Executive summary slide
Executive summary slideExecutive summary slide
Executive summary slide
 
World War
World WarWorld War
World War
 
Proximo Tech Soft
Proximo Tech SoftProximo Tech Soft
Proximo Tech Soft
 
Resume SKP
Resume SKPResume SKP
Resume SKP
 
CATÁLOGO INZEIN
CATÁLOGO INZEINCATÁLOGO INZEIN
CATÁLOGO INZEIN
 
Proximo
ProximoProximo
Proximo
 
Aprendendo a programar - Programação Procedural vs OOP
Aprendendo a programar - Programação Procedural vs OOPAprendendo a programar - Programação Procedural vs OOP
Aprendendo a programar - Programação Procedural vs OOP
 

Similar to Java

java01.ppt
java01.pptjava01.ppt
java01.ppt
Godwin585235
 
Java PPt.ppt
Java PPt.pptJava PPt.ppt
Java PPt.ppt
NavneetSheoran3
 
INTRODUCTION TO JAVA
INTRODUCTION TO JAVAINTRODUCTION TO JAVA
INTRODUCTION TO JAVA
Pintu Dasaundhi (Rahul)
 
Java tutorial for beginners-tibacademy.in
Java tutorial for beginners-tibacademy.inJava tutorial for beginners-tibacademy.in
Java tutorial for beginners-tibacademy.in
TIB Academy
 
core java course online
core java course onlinecore java course online
core java course online
Vibrant Technologies & Computers
 
java development companies in Bangalore
java development companies in Bangalorejava development companies in Bangalore
java development companies in Bangalore
Shreya Anand
 
Introduction to java programming
Introduction to java programmingIntroduction to java programming
Introduction to java programming
ASIT Education
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
FakeBuddy2
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
ssuser73c6451
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
ShivamChaturvedi67
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
ROGNationYT
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
JyoGen
 
mukul Dubey.pptx
mukul Dubey.pptxmukul Dubey.pptx
mukul Dubey.pptx
CodeHome
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
SouravGhosh305827
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
SachinBhosale73
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
BabekEsedli
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
MENACE4
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
MansiDongare2
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
priyanshugautam46
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
archibhartiya
 

Similar to Java (20)

java01.ppt
java01.pptjava01.ppt
java01.ppt
 
Java PPt.ppt
Java PPt.pptJava PPt.ppt
Java PPt.ppt
 
INTRODUCTION TO JAVA
INTRODUCTION TO JAVAINTRODUCTION TO JAVA
INTRODUCTION TO JAVA
 
Java tutorial for beginners-tibacademy.in
Java tutorial for beginners-tibacademy.inJava tutorial for beginners-tibacademy.in
Java tutorial for beginners-tibacademy.in
 
core java course online
core java course onlinecore java course online
core java course online
 
java development companies in Bangalore
java development companies in Bangalorejava development companies in Bangalore
java development companies in Bangalore
 
Introduction to java programming
Introduction to java programmingIntroduction to java programming
Introduction to java programming
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
mukul Dubey.pptx
mukul Dubey.pptxmukul Dubey.pptx
mukul Dubey.pptx
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 

Recently uploaded

Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 

Recently uploaded (20)

Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 

Java

  • 2. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build ◦ stand-alone Java programs ◦ Java applets, which run within browsers e.g. Netscape Example programs
  • 3. Why Java? It’s the current “hot” language It’s almost entirely object-oriented It has a vast library of predefined objects and operations It’s more platform independent ◦ this makes it great for Web programming It’s more secure It isn’t C++
  • 4. Applets, Servlets and Applications An applet is designed to be embedded in a Web page, and run by a browser Applets run in a sandbox with numerous restrictions; for example, they can’t read files and then use the network A servlet is designed to be run by a web server An application is a conventional program
  • 5. Building Standalone JAVA Programs (on UNIX) Prepare the file foo.java using an editor Invoke the compiler: javac foo.java This creates foo.class Run the java interpreter: java foo
  • 6. Java Virtual Machine The .class files generated by the compiler are not executable binaries ◦ so Java combines compilation and interpretation Instead, they contain “byte-codes” to be executed by the Java Virtual Machine ◦ other languages have done this, e.g. UCSD Pascal This approach provides platform independence, and greater security
  • 7.
  • 8. HelloWorld (standalone) Note that String is built in println is a member function for the System.out class public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } }
  • 9. Comments are almost like C++ /* This kind of comment can span multiple lines */ // This kind is to the end of the line /** * This kind of comment is a special * ‘javadoc’ style comment */
  • 10. Primitive data types are like C Main data types are int, double, boolean, char Also have byte, short, long, float boolean has values true and false Declarations look like C, for example, ◦ double x, y; ◦ int count = 0;
  • 11. Expressions are like C 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
  • 12. Control statements are like C 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 !
  • 13. Control statements II Java also introduces the try statement, about which more later switch (n + 1) { case 0: m = n - 1; break; case 1: m = n + 1; case 3: m = m * n; break; default: m = -n; break; }
  • 14. Java isn't C! In C, almost everything is in functions In Java, almost everything is in classes There is often only one class per file There must be only one public class per file The file name must be the same as the name of that public class, but with a .java extension
  • 15. Java program layout A typical Java file looks like: import java.awt.*; import java.util.*; public class SomethingOrOther { // object definitions go here . . . } This must be in a file named SomethingOrOther.java !
  • 16. What is a class? Early languages had only arrays ◦ all elements had to be of the same type Then languages introduced structures (called records, or structs) ◦ allowed different data types to be grouped Then Abstract Data Types (ADTs) became popular ◦ grouped operations along with the data
  • 17. So, what is a class? A class consists of ◦ a collection of fields, or variables, very much like the named fields of a struct ◦ all the operations (called methods) that can be performed on those fields ◦ can be instantiated A class describes objects and operations defined on those objects
  • 18. Name 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!
  • 19. The class hierarchy Classes are arranged in a hierarchy The root, or topmost, class is Object Every class but Object has at least one superclass A class may have subclasses Each class inherits all the fields and methods of its (possibly numerous) superclasses
  • 20. An example of a class class Person { String name; int age; void birthday ( ) { age++; System.out.println (name + ' is now ' + age); } }
  • 21. Another example of a class class Driver extends Person { long driversLicenseNumber; Date expirationDate; }
  • 22. Creating and using an object Person john; john = new Person ( ); john.name = "John Smith"; john.age = 37; Person mary = new Person ( ); mary.name = "Mary Brown"; mary.age = 33; mary.birthday ( );
  • 23. An array is an object Person mary = new Person ( ); int myArray[ ] = new int[5]; ◦ or: int myArray[ ] = {1, 4, 9, 16, 25}; String languages [ ] = {"Prolog", "Java"};
  • 24. www.proximo.in Address: No:3, II Floor, 100 ft Road, BTM Layout, II Stage, Bangalore, Karnataka (560 076) India Tel: +91 (0)80 4900 1234 Mail: info@proximo.in CONTACT US Thanks for watching