Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
33 views
1.introduction To Java
Uploaded by
PRAVEEN
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save 1.Introduction to Java For Later
Download
Save
Save 1.Introduction to Java For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
33 views
1.introduction To Java
Uploaded by
PRAVEEN
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save 1.Introduction to Java For Later
Carousel Previous
Carousel Next
Save
Save 1.Introduction to Java For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 23
Search
Fullscreen
Introduction to Java Vasily Strelnikov 1U-FIELD DELIVERY Cee ee ee eee eetCourse Goals In this course, you learn how to implement application logic using Java SE: + Describe the object-oriented programming approach + Explain Java syntax and coding conventions + Use Java constructs and operators Use core Java APIs, such as Collections, Streams, IO, and Concurrency + Deploy Java SE applications Vasily Strelnikov SENIOR PRINCIPAL INSTRUCTOR, OU-FIELO DELIVERY ORACLE UNIVERSITY Ea Cony ©2020, Oracle anos alias, i ahs reserve,Audience The target audience includes those who: + Have some non-Java programming experience and want to learn Java, + Have basic knowledge of Java and want to improve it + Prepare for the Java SE 11 Certification exams CCopynght ©2020, Gace andor aise. Al igs asd,Course Structure Lesson 4: Introduction to Java Lesson 2: Primitive Types, Operators, and Flow Control Statements Lesson 3: Text, Date, Time, and Numeric Objects Lesson 4: Classes and Objects Lesson 5: Improved Class Design Lesson 6: Inheritance Lesson 7: Interfaces Lesson 8: Arrays and Loops Lesson 9: Collections Lesson 10: Nested Classes and Lambda Expressions Lesson 11: Java Streams API Lesson 12: Handle Exceptions and Fix Bugs Lesson 13: Java IO API Lesson 14: Java Concurrency and Multithreading Lesson 15: Java Modules z Extras: + Appendix A: Annotations + Appendix B: JDBC API + Appendix C: Security + Appendix D: Generics + Appendix E: Cloud DeploymentCourse Practices During the course practice sessions, you: + Explore the features of Java language Apply the knowledge gained throughout the course to develop a product management application The practice environment uses: + JDK11 + JShell + NetBeans 11 Copyright© 2020, Orel andre flats, Al ras reserved.Lesson Objectives After completing this lesson, you should be able to: + Discover Java language origins and use-cases + Explain Java portability and provider neutrality + Explain object-oriented concepts + Describe Java syntax and coding conventions + Create Java class with main method + Compile and execute a Java application Copyright ©2020, Ola ands afstes. Al igh reservedWhat Is Java? + General purpose programming language similar to C and C++ + Object-Oriented and Platform-Independent * Originally designed in 1995 for use in consumer electronics + Modem uses include writing applications for internet of things, Cloud computing, and so on. & + This course covers Java SE (Standard Edition) version 11 => = ‘Java Editions: Java Card - Smart card Edition Java ME ~ Micro Edition Java SE - Standard Edition Java MP - Micro Profile Java EE - Enterprise Edition +} Java SE is the base edition on which other editions are based. ava Copyright © 2020, Oracle andlor its affitates. All rights reserved,How Java Works? Java is a platform-independent programming language. + Java source code is written as plain text . java files. * Source code is compiled into byte-code . class files for JVM. + Java Virtual Machine must be installed on a target computer. + JVM executes your application by translating Java byte-code instructions to platform-specific code. Ratna oe (QS public class Helloworld( p public static void main(String{} args) ( = System.out.printin("Hello World"); , ’ (001200) 320011 dU | davac Hentoworia. java “Note: A Java program has to be compiled only once to work on any platform! e SANE comp ©2101 Oa ern MiClasses Class and Object are two key object-oriented concepts. Java code is structured with classes. + Class represents a type of thing or a concept, such as Dog, Cat, Ball, Person. + Each class defines what kind of information (attributes) it can store: - ADog could have a name, color, size. ~ ABall would have type, material, and so on. + Each class defines what kind of behaviors (operations) containing program logic (algorithms) itis capable of: ~ ADog could bark and fetch a Ball. - ACat could meow but is not likely to play fetch. class Person ( class Dog { void play() { String name; Dog dog = new Dog()s fetch (Ball ball) dog.name = "Rex"; ball. find(); Bali ball = new Ball(); ball.chew()? dog. fetch (ball); , , } e tat + Objects are covered next Comyn ©2020, rate andor flats. Al igh reseed, °Objects ‘An Object is a specific instance (example of) a Class. + Each object would be capable of having specific values for each attribute defined by a Es class that represents its type. For example: ~ A dog could be called Fido, and be brown and small EK. - Another could be called Rex, and be orange and big Fido Ff + To operate on an object, you can reference it using a variable of a relevant type. + Each object would be capable of behaviors defined by a class that represents its type: Rex - Atrun time, objects invoke operations upon each other to execute program logic. class Person { class Dog { void play() ( String name; Dog dog = new Dog); fetch (Ball ball) { dog.name = "Rex"; ball. find( Ball ball = new Ball(); ball.chew(); dog. fetch (ball) + ) ) ) ) _—— Java ceca Oude nr ane MewesInheritance You can reuse (inherit) attributes and behaviors across class hierarchy. * Classes can form hierarchical relationships. + Superclass represents a more generic, parent type (living organism). + Superclasses define common attributes and behaviors (eat, propagate). + Asubclass represents a more specific, child type (animal, plant, and so on). + There could be any number of levels in the hierarchy, from very generic to very 9 specific child types (dog, cat, and so on). + Subclasses inherit all attributes and behaviors from their parents. + Subclasses can define more specific attributes and behaviors (swim, fly). class Animal extends LivingOrganisn { // generic attributes and behaviours B inherited class Dog extends Animal ( 7/ specific attributes and behaviours — Nz Copyright © 2020, Oracle andlor is afiiatos. All rights reserved. WJava APIs Java Development Kit (JDK) provides hundreds of classes for various programming purposes: To represent basic data types, for example, String, LocalDateTime, BigDecimal, and so on To manipulate collections, for example, Enumeration, ArrayList, HashMap, and so on To handle generic behaviors and perform system actions, for example, System, Object, Class, and so on To perform input/output (V/O) operations, for example, FileInput Stream, FileOutput Stream, and so on Many other API classes are used to access databases, manage concurrency, enable network communications, execute scripts, manage transactions, security, logging, build graphical user interfaces, and so on ++ Application Programming Interface (API) is a term that describes a collection of classes that are designed to serve a common purpose. +FAll Java APIS are thoroughly documented for each version of the 6 language. For example, Java 11 documentation can be found at: = Java httos://docs.oracle.com/en/iavaljavase/‘ 1/docs/api/ = fs ENE) 0 andor sass Ml gs reserved 2Java Keywords, Reserved Words, and a Special Identifier Keywords available since 1.0 ry eee ce oe Keywords no longer in use else extends try enum Keywords added in 1.2 continue interface catch module ae F real class finally requires Keywords added in 1.4 for static throw transitive Keywords added in 5.0 do final throws xports to Keywords added in 9.0 while return uses switch transient provides case void we Reserved words for literals values Gefault byte ae private short identi i protected int synchronized true Special identifier added in 10 Preis me sleeeaa =n. import char goto pull Package float const abstract double stricttp var eS Notes ++ Keywords and Literals cannot be used as identifiers (names of classes, variables, methods, and so on). +f Actual use and meaning of these keywords and literals are covered later in this course. Java Copyright © 2020, Oracle andior its affiliates. All rights reserved. 8Java Naming Conventions + Java is case-sensitive; Dog is not the same as dog. + Package name is a reverse of your company domain name, plus the naming system adopted within your company. + Class name should be a noun, in mixed case with the first letter of each word capitalized, + Variable name should be in mixed case starting with a lowercase letter; further words start with capital letters. + Names should not start with numeric characters (0-9), underscore _ or dollar $ symbols. + Constant name is typically written in uppercase with underscore symbols between words. + Method name should be a verb, in mixed case starting with a lowercase letter, further words start with capital letters. com.oracle.demos.animals | package: animals ShepheraDog Glass: Shepherd Dog 1 shepherdDog MIN_SIZE giveMePaw +Note: The use of the _ symbol as a first or only character in a variable name produces a compiler warning in Java 8 and an error in Java 9 onward. java) Commo 6ain Once tr tuian igiemnedJava Basic Syntax Rules * All Java statements must be terminated with the " ; " symbol. * Code blocks must be enclosed with " {" and" }" symbols. + Indentations and spaces help readability, but are syntactically irrelevant. Package com.oracle.demos.animals; class Dog ( void fetch() { while (ball == null) { keepLooking () 7 ) void makeNoise() { if (ball wll) { droppall () ; ) else ( bark(); d } oe ‘Note: Example shows some constructs such as if/ese and while that are covered later in the course. Copyright © 2020, Orleans sins Alright reser, 16Define Java Class + Class name is typically represented by one or more nouns, for example, Dog, SabreToothedCat, Person. *+ Class must be saved into a file with the same name as the class and extension . java. + Classes are grouped into packages. + Packages are represented as folders where class files are saved. + Package name is 4 reverse of your company domain name, plus a naming system adopted within your company. Example: com. oracle.demos, org.acme. something + Package and class name must form a unique combination. package
Class
( 1 pr package con.oracle.denos.animals: elass Dog { 7 the rest of thie class code /somepath/con/oracle/demos/animals/Dog. java 5 2G ee a “‘FNote: If package definition is missing, class would belong to a "default package and would not be placed into any package folder. However, this is not a recommended practice. java CorMMCO2I Once mdr dee NoordAccess Classes Across Packages To access a class in another package: + Prefix the class name with the package name + Use the import statement to import specific classes or the entire package content = The import of all classes from the java.1ang.* package is implicitly assumed. The example shows three alternative ways of referencing the class Dog in the package animals from the class Owner in the package people: package eninals; public class Dog { | , oe package people; package people: package people: Public class Owner {|| import aninals.Dog; import aninais.*; | ‘aninals.dog myDog: || public class Owner {| | public class Owner { i ‘Dog myDogs Dog myDogs ) ) SS Notes + Imports are not present in a compiled code. An import statement has no effect at runtime efficiency of the class. Itis ‘a simple convenience to avoid prefixing class name with package name throughout your source code. + Access modifiers (such as pub! ic) are explained in the following slide, 18Use Access Modifiers Access modifiers describe the visibility of classes, variables, and methods. + public - Visible to any other class + protected - Visible to classes that are in the same package or to subclasses +
- Visible only to classes in the same package + private - Visible only within the same class package
; package b; Unport
.
: import a. import
.*; Public class ¥ extends x [
clase
( Public void dothings() { | package a7
x= new X(7 public class x ( Xaccess modifier>
yt public ¥ yl; x , ee ae vy oe ¥3i 2 1937 14; rivate x vas ) T ) ee Notes —— +f
means that no access modifier is explicitly set. + Subclass-Superclass relationship (use of the extends keyword) is covered later in the course. ++ Any nonprivate parts of your class should be kept as stable as possible, because changes of such code may adversely affect any number of other classes that may be using your code. Eve Copyright © 2020, Oracle and/or its affiiates. Al rights reserved. 9 - oeCreate Main Application Class The main method is the entry point into your application. + Itis the starting point of program execution. + The method name must be called main. + Itmust be pub1ic. You intend to invoke this method from outside of this class. + Itmust be static. Such methods can be invoked without creating an instance of this class. + Itmust be voi. It does not return a value. It must accept array of String objects as the only parameter. (The name of this parameter "args" is irrelevant.) package demos; public class Whatever ( public static void main(String{] args) { // program execution starts here ) ) ++ Note: Use of static and void keywords and handling of arrays are covered later in the course. rCompile Java Program Compile classes with the javac Java compiler. + The -classpath or ~cp parameter points to locations of other classes that may be required to compile your code. + The -d parameter points to a path to store compilation result. (The compiler creates package subfolders with compiled class files in this path.) + Provide path to source code. Javac -cp /project/clas: es -d /project/classes /project/sources/denos/Whatever. java package demos; eae public class Whatever { Public static void main(String[] args) { // program execution starts here ) /project/classes/denos/thatever.class | Ea Copyrght ©2020, race ano ste. Alihts eserves, 2 OwExecute Java Program Execute program using java executable Java Virtual Machine (JVM). + Specify classpath or -cp to point to folders where your classes are located. + Specify fully qualified class name. Use package prefix; do not use the .class extension. + Provide a space separated list of parameters after the class name. Access command-line parameters: package demos; + Use array object to access parameters. Public class Whatever (ay + Array index starts at 0 (frst parameter). Disteing raremiiciecaaniir System.out.println ("Hello “tparam1); demos Whatever Jo John "A Name” Jane java -cp /project/cl: — Hello John + Since Java 11, it is also possible to run single-file source code as if it is a compiled class. JVM will interpret your code, but no compiled class file would be created: a )Comments and Documentation + Code Comments can be placed anywhere in your source code. + Documentation Comments: - May contain HTML markups Single iin - May contain descriptive tags prefixed with ¢ sing ~ Are used by the javadoc tool to generate documentation Pack: Class Whatever ee <—_ 6} The de Whatever} cla: a x * represents an example of demos Whatever Gavaaes » ascuaanbatiod oamecnt public class what extends The whatever class represents an example of docum = Javadoc -d
sourcepath
Author subpackages
+ Note: All APIs in the Java development kit are documented using the javadoc utilitySummary In this lesson, you should have learned how to: + Discover Java language origins and use-cases + Explain Java portability and provider neutrality Explain object-oriented concepts + Describe Java syntax and coding conventions + Create a Java class by using the ma in method + Compile and execute a Java application
You might also like
Unit-1 PPT 20CS3102 Oops
PDF
No ratings yet
Unit-1 PPT 20CS3102 Oops
114 pages
Java 23 Reg Unit1 Notes
PDF
No ratings yet
Java 23 Reg Unit1 Notes
26 pages
Java Programming Lect1
PDF
No ratings yet
Java Programming Lect1
92 pages
Unit 01 Java Programming
PDF
No ratings yet
Unit 01 Java Programming
144 pages
Object Oriented Programming Lecture-1: CSE 201 Conducted by Sarwar Morshed Email: Mobile: 01947179930
PDF
No ratings yet
Object Oriented Programming Lecture-1: CSE 201 Conducted by Sarwar Morshed Email: Mobile: 01947179930
24 pages
Getting Started With Java Programming
PDF
No ratings yet
Getting Started With Java Programming
13 pages
Cs8392 Unit I Oop Lect
PDF
No ratings yet
Cs8392 Unit I Oop Lect
90 pages
Java
PDF
No ratings yet
Java
24 pages
Unit 1 Java
PDF
No ratings yet
Unit 1 Java
39 pages
Core Java - Part1
PDF
No ratings yet
Core Java - Part1
21 pages
Java Reaseach Paper
PDF
No ratings yet
Java Reaseach Paper
3 pages
Bacs A: Sensitivity - Java
PDF
No ratings yet
Bacs A: Sensitivity - Java
6 pages
JAVA
PDF
No ratings yet
JAVA
23 pages
Java Introduction
PDF
No ratings yet
Java Introduction
89 pages
1. Introduction to OOP
PDF
No ratings yet
1. Introduction to OOP
16 pages
Two Paradigms: Process-Oriented Model
PDF
No ratings yet
Two Paradigms: Process-Oriented Model
25 pages
Chapter 1_Module 1
PDF
No ratings yet
Chapter 1_Module 1
36 pages
Data Structures, Algorithems & Programming in Java: Code:ITM 311
PDF
No ratings yet
Data Structures, Algorithems & Programming in Java: Code:ITM 311
33 pages
History and Features of Java
PDF
No ratings yet
History and Features of Java
65 pages
UNIT-I A Java
PDF
No ratings yet
UNIT-I A Java
47 pages
cs8392oopuniti-181023033704
PDF
No ratings yet
cs8392oopuniti-181023033704
89 pages
Java Programming For Beginners: The Key Concepts of Java As An Object-Oriented Programming Language
PDF
No ratings yet
Java Programming For Beginners: The Key Concepts of Java As An Object-Oriented Programming Language
8 pages
Java R20 - UNIT-1
PDF
No ratings yet
Java R20 - UNIT-1
25 pages
Lecture Notes and Lab Handouts Object Oreinted Programming (Itec / Seng - 321) Week. 1 Topic Covered
PDF
No ratings yet
Lecture Notes and Lab Handouts Object Oreinted Programming (Itec / Seng - 321) Week. 1 Topic Covered
8 pages
Java Lecture Notes
PDF
100% (1)
Java Lecture Notes
66 pages
Java
PDF
No ratings yet
Java
13 pages
Java Summary
PDF
No ratings yet
Java Summary
208 pages
Java 01
PDF
No ratings yet
Java 01
29 pages
Java 1
PDF
No ratings yet
Java 1
32 pages
1.Java-review,History, Puzz Words, JVM
PDF
No ratings yet
1.Java-review,History, Puzz Words, JVM
52 pages
001 - Introduction To Java
PDF
No ratings yet
001 - Introduction To Java
16 pages
Fundamentals of Programming in Java
PDF
No ratings yet
Fundamentals of Programming in Java
35 pages
java-r20-unit-1
PDF
No ratings yet
java-r20-unit-1
26 pages
Core Java-2
PDF
No ratings yet
Core Java-2
216 pages
Introduction To Java: BY Umar Zia Iimt I.E.T (Computer Science)
PDF
No ratings yet
Introduction To Java: BY Umar Zia Iimt I.E.T (Computer Science)
22 pages
Programming Language II CSE-215: Dr. Mohammad Abu Yousuf Yousuf@juniv - Edu
PDF
No ratings yet
Programming Language II CSE-215: Dr. Mohammad Abu Yousuf Yousuf@juniv - Edu
34 pages
To Java Programming: Christ College - Pune Presented by David Thomas
PDF
No ratings yet
To Java Programming: Christ College - Pune Presented by David Thomas
19 pages
Java Training Tutorials
PDF
No ratings yet
Java Training Tutorials
11 pages
Java & C++ Interview
PDF
No ratings yet
Java & C++ Interview
12 pages
Lecture One
PDF
No ratings yet
Lecture One
27 pages
UNIT-1
PDF
No ratings yet
UNIT-1
176 pages
Java Tutorial: Prerequisites
PDF
No ratings yet
Java Tutorial: Prerequisites
176 pages
Java101
PDF
No ratings yet
Java101
35 pages
The Concept of Java Classes and Objects
PDF
No ratings yet
The Concept of Java Classes and Objects
51 pages
CS8392 Object Oriented Programming Notes 1
PDF
No ratings yet
CS8392 Object Oriented Programming Notes 1
238 pages
New - 2-Ing - OOP-S1-Chap 0
PDF
No ratings yet
New - 2-Ing - OOP-S1-Chap 0
35 pages
Unit 1 Java
PDF
No ratings yet
Unit 1 Java
37 pages
Lecture 1
PDF
No ratings yet
Lecture 1
31 pages
Programming in Java
PDF
No ratings yet
Programming in Java
64 pages
Core Jawa 111
PDF
No ratings yet
Core Jawa 111
24 pages
Language Fundamentals
PDF
No ratings yet
Language Fundamentals
33 pages
Java Programming
PDF
No ratings yet
Java Programming
7 pages
Java
PDF
100% (1)
Java
69 pages
Java
PDF
No ratings yet
Java
5 pages
Oops With Java Bcs306a Notes
PDF
No ratings yet
Oops With Java Bcs306a Notes
81 pages
MOD1 PPT-chap 1
PDF
No ratings yet
MOD1 PPT-chap 1
139 pages
FEATURES OF JAVA - PPTM
PDF
No ratings yet
FEATURES OF JAVA - PPTM
17 pages
CoreJava Day1
PDF
No ratings yet
CoreJava Day1
126 pages
Oops Unit 4
PDF
No ratings yet
Oops Unit 4
21 pages