SlideShare ist ein Scribd-Unternehmen logo
1 von 31
JAVA
Fundamental of
java
Prepared by
Miss. Arati A. Gadgil
2
Java
Java was developed in the early 90s by Sun Microsystems
Java is a high-level language.
There are many features of java. They are also known as
java buzzwords.
Simple
Java omits many rarely used, poorly understood, confusing
features of C++. Say : No Pointer! No dynamic delete.
3
Object Oriented
Object –oriented design is a technology that focuses design
on the data (object) and on the interfaces to it.
Everything is an object, everything will become a class in
Java. Every java program, in top- level view, is classes.
Robust
The single biggest difference between Java and C/C++ is
that Java has “a inner safe pointer-model”, therefore it
eliminates the possibility of overwriting memory and
corrupting data, so programmers feel very safe in coding.
4
Distributed
Basically, Java is for Net-Work application, for WEB
project. Java can open and access “objects” across the Net via
URLs (Uniform Resource Locator)
eg. “http//:gamut.neiu.edu/~ylei/home.html”, with the same
ease as when accessing a local file system
Platform Independent
Java code can be run on multiple platforms e.g. Windows,
Linux, Sun Solaris,Mac/OS etc. Java code is compiled by the
compiler and converted into bytecode.This bytecode is a
platform independent code because it can be run on multiple
platforms i.e. Write Once and Run Anywhere(WORA).
5
Secured
Java is secured because:
No explicit pointer,Programs run inside virtual machine
sandbox also,
•Classloader- adds security by separating the package for the
classes of the local file system from those that are imported
from network sources.
•Bytecode Verifier- checks the code fragments for illegal code
that can violate access right to objects.
•Security Manager- determines what resources a class can
access such as reading and writing to the local disk
6
Architecture-neutral
The compiler generates an architecture-neutral object file
format. The compile code can run on many processors ,given
the presence of the runtime system. The java compiler does
this by generting bytecode instruction which have nothing to
do with a particular computer architecture.
Portable
We may carry the java bytecode to any platform.
High-performance
Java is faster than traditional interpretation since byte code is
"close" to native code still somewhat slower than a compiled
language (e.g., C++)
7
Multi-threaded
A thread is like a separate program, executing concurrently.
We can write Java programs that deal with many tasks at once
by defining multiple threads. The main advantage of multi-
threading is that it shares the same memory. Threads are
important for multi-media, Web applications etc.
Dynamic
In number of ways, java is more dynamic language than C or
C++.It was designed to adapt to an evolving environment.
Libraries can freely add new methods and instance variables
without any effect on their clients. In java finding out runtime
type information is straightforward.
8
Java Virtual Machine
The .class files generated by the compiler are not executable
binaries, Java combines compilation and interpretation.
Instead, they contain “byte-codes” to be executed by the Java
Virtual Machine.
This approach provides platform independence, and greater
security.
The JVM performs following main tasks:
•Loads code
•Verifies code
•Executes code
•Provides runtime environment
9
JRE
JRE is an acronym for Java Runtime Environment. It is used
to provide runtime environment.It is the implementation of
JVM. It physically exists.It contains set of libraries + other
files that JVM uses at runtime.
JDK
JDK is an acronym for Java Development Kit. It physically
exists. It contains JRE + development tools
10
JVM
Java Virtual Machine (JVM) is an abstract computing
machine. Java Runtime Environment (JRE) is an
implementation of the JVM. Java Development Kit (JDK)
contains JRE along with various development tools like Java
libraries, Java source compilers, Java debuggers, bundling and
deployment tools.
11
Relations between JVM JRE JDK
12
JIT
JIT refers to execution engine in few of JVM
implementations, one that is faster but requires more memory,
is a just-in-time compiler. In this scheme, the bytecodes of a
method are compiled to native machine code the first time the
method is invoked.
JIT refers to execution engine in few of JVM
implementations, one that is faster but requires more
memory,is a just-in-time compiler. In this scheme, the
bytecodes of a method are compiled to native machine code
the first time the method is invoked.
13
Java Bytecode
Java bytecode is the instruction set of the Java virtual
machine. Eachbytecode is composed by one, or in some cases
two, bytes that represent the instruction (opcode), along with
zero or more bytes for passing parameters..
Bytecode is nothing but the intermediate representation of
Java source code which is produced by the Java compiler by
compiling that source code. This byte code is an machine
independent code.It is not an completely a compiled code but
it is an intermediate code somewhere in the middle which is
later interpreted and executed by JVM
14
HotSpot, released as the "Java HotSpot Performance Engine"is
a Java virtual machine for desktops and servers, maintained and
distributed by Oracle Corporation. It features techniques such as just-
in-time compilation and adaptive optimization designed to improve
performance.
Sun intended to write a new just-in-time (JIT) compiler for the
newly developed virtual machine.This new compiler would give rise
to the name "HotSpot", which derives from the fact that, as the
software runs Java bytecode, it continually analyzes the program's
performance for "hot spots" which are frequently or repeatedly
executed. These are then targeted for optimization, leading to high-
performance execution with a minimum of overhead for less
performance-critical code
Java HotSpot
15
Sun's JRE features two virtual machines, one called Client and the
other Server. The Client version is tuned for quick loading. It makes use
of interpretation. The Server version loads more slowly, putting more
effort into producing highly optimized JI compilations, that yield higher
performance. Both VMs compile only often-run methods, using a
configurable invocation-count threshold to decide which methods to
compile.
The HotSpot Java virtual machine is written in C++. As stated on the
HotSpot web page, the source contains approximately 250,000 lines of
code.
Hotspot provides:
•A class loader
•A bytecode interpreter
•Client and Server virtual machines, optimized for their respective uses
•Several garbage collectors
•A set of supporting runtime libraries
16
The main() method
public static void main(String args[])
{
...
}
public--- the interpreter can call it.
static ----It is a static method belonging to the class.
void -----It does not return a value.
String----It always has an array of String objects as its formal parameter.
the array contains any arguments passed to the program on the
command line.The source file’s name must match the class name which
main method is in.
17
Source File Declaration Rules
There can be only one public class per source code file.
Comments can appear at the beginning or end of any line in the source
code file; they are independent of any of the positioning rules discussed
here.
If there is a public class in a file, the name of the file must match the
name of the public class.
For example, a class declared as public class Dog { }must be in a source
code file named Dog.java.
If the class is part of a package, the package statement must be the first
line in the source code file, before any import statements that may be
present.
18
If there are import statements, they must go between the package
statement (if there is one) and the class declaration. If there isn't a
package statement, then the import statement(s) must be the first line(s)
in the source code file.
If there are no package or import statements, the class declaration must
be the first line in the source code file.
import and package statements apply to all classes within a source
code file. In other words, there's no way to declare multiple classes in a
file and have them in different packages, or use different imports.
A file can have more than one nonpublic class.
Files with no public classes can have a name that does not match any of
the classes in the file
19
Comments
/* 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
*/
20
Primitive types
•int 4 bytes
•short 2 bytes
•long 8 bytes
•byte 1 byte
•float 4 bytes
•double 8 bytes
•char Unicode encoding (2 bytes)
•boolean {true,false}
Behaviors is
exactly as in
C++
21
• Constants
37 integer
37.2 float
42F float
0754 integer (octal)
0xfe integer (hexadecimal)
• Comparison operators
== equal
!= not equal
< less than
> greater than
<= less than or equal
>= greater than or equal
22
Variable declaration
type variable-name;
Meaning: variable <variable-name> will be a variable of type <type>
Where type can be:
int //integer
double //real number
Example:
int a, b, c;
double x;
int sum;
23
String is an Object
Constant strings as in C, does not exist
 The function call show(“Hello”) creates a String object, containing
“Hello”, and passes reference to it to show.
 The String object is a constant. It can’t be changed using a reference
to
it.
24
Writing to user (output)
System.out.println(variable-name);
prints the value of variable <variable-name> to the user
System.out.println(“any message “);
prints the message within quotes to the user
System.out.println(“hello” + “world” + a + “plus“ + b);
assuming the value of a is 3 and of b is 7, it prints
helloworld3plus7
Note: System.out.println() always prints on a new line.
25
Example
/*
This program illustrates the System.out.println command.
*/
public class Hello
{
public static void main (String args[])
{
System.out.println(“This is my first Java program!”);
System.out.print(“I like Java.”);
System.out.print(“I think Java is cool.”);
} // end of main
} // end of class
26
Example
/*
Printing ages.
*/
public class MyFirstJavaProgram
{
public static void main (String args[])
{
int myAge, myFriendAge; /* declare two integer
variables */
myAge = 20;
myFriendAge = myAge + 1; //one year older
System.out.println(“Hello, I am “ +myAge + “years old,
and my friend is “ + myFriendAge + “ years old”);
System.out.println(“Goodbye”);
} // end of main
} // end of class
27
Flow control
if/else
do/while
for
switch
If(x==4) {
// act1
} else {
// act2
}
int i=5;
do {
// act1
i--;
} while(i!=0);
int j;
for(int i=0;i<=9;i++)
{
j+=i;
}
char
c=IN.getChar();
switch(c) {
case ‘a’:
case ‘b’:
// act1
break;
default:
// act2
}
28
Big Numbers
If the precision of the basic integer and floating-point types is not
sufficient, you can turn to a couple of handy classes in
the java.math package, called BigInteger and BigDecimal. These are
classes for manipulating numbers with an arbitrarily long sequence of
digits. The BigInteger class implements arbitrary precision integer
arithmetic, and BigDecimal does the same for floating-point numbers.
Use the static valueOf method to turn an ordinary number into a big
number:
BigInteger a = BigInteger.valueOf(100);
BigInteger c = a.add(b); // c = a + b
BigInteger d = c.multiply(b.add(BigInteger.valueOf(2)));
// d = c * (b + 2)
29
Array
•Array is an object
• Array size is fixed
A[] arr; // nothing yet …
arr = new A[4]; // only array of pointers
for(int i=0 ; i < arr.length ; i++)
arr[i] = new Animal();
30
Arrays - Multidimensional
• In C++
Animal arr[2][2]
Is:
• In Java
What is the type of
the object here ?
A[][] arr=
new A[2][2]
Thank You
31

Weitere ähnliche Inhalte

Was ist angesagt?

Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)Manisha Keim
 
Collections In Java
Collections In JavaCollections In Java
Collections In JavaBinoj T E
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handlingkamal kotecha
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVAVINOTH R
 
Java string handling
Java string handlingJava string handling
Java string handlingSalman Khan
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And MultithreadingShraddha
 
Core java concepts
Core java  conceptsCore java  concepts
Core java conceptsRam132
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core javamahir jain
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handlingNahian Ahmed
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaCPD INDIA
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaSaba Ameer
 

Was ist angesagt? (20)

Java I/O
Java I/OJava I/O
Java I/O
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Core java
Core javaCore java
Core java
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Java string handling
Java string handlingJava string handling
Java string handling
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
JAVA PROGRAMMING
JAVA PROGRAMMING JAVA PROGRAMMING
JAVA PROGRAMMING
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
 
Java Collections
Java  Collections Java  Collections
Java Collections
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Generics
GenericsGenerics
Generics
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java threads
Java threadsJava threads
Java threads
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 

Andere mochten auch

Andere mochten auch (17)

Chapter 4 Powerpoint
Chapter 4 PowerpointChapter 4 Powerpoint
Chapter 4 Powerpoint
 
C0 review core java1
C0 review core java1C0 review core java1
C0 review core java1
 
Introduction to the Java(TM) Advanced Imaging API
Introduction to the Java(TM) Advanced Imaging APIIntroduction to the Java(TM) Advanced Imaging API
Introduction to the Java(TM) Advanced Imaging API
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
 
Eo gaddis java_chapter_02_5e
Eo gaddis java_chapter_02_5eEo gaddis java_chapter_02_5e
Eo gaddis java_chapter_02_5e
 
Java Programming - 03 java control flow
Java Programming - 03 java control flowJava Programming - 03 java control flow
Java Programming - 03 java control flow
 
Intro to C++ Basic
Intro to C++ BasicIntro to C++ Basic
Intro to C++ Basic
 
Java for beginners
Java for beginnersJava for beginners
Java for beginners
 
Core Java Basics
Core Java BasicsCore Java Basics
Core Java Basics
 
Java Programming - 01 intro to java
Java Programming - 01 intro to javaJava Programming - 01 intro to java
Java Programming - 01 intro to java
 
Basics of Java
Basics of JavaBasics of Java
Basics of Java
 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Java programming course for beginners
Java programming course for beginnersJava programming course for beginners
Java programming course for beginners
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 

Ähnlich wie Java basic

Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Mr. Akaash
 
Javanotes ww8
Javanotes ww8Javanotes ww8
Javanotes ww8kumar467
 
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, MysuruNithin Kumar,VVCE, Mysuru
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)Shaharyar khan
 
Top 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdfTop 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdfUmesh Kumar
 
College Project - Java Disassembler - Description
College Project - Java Disassembler - DescriptionCollege Project - Java Disassembler - Description
College Project - Java Disassembler - DescriptionGanesh Samarthyam
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1Qualys
 
Presentación rs232 java
Presentación rs232 javaPresentación rs232 java
Presentación rs232 javaJohn Rojas
 

Ähnlich wie Java basic (20)

Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
JAVA for Every one
JAVA for Every oneJAVA for Every one
JAVA for Every one
 
Javanotes ww8
Javanotes ww8Javanotes ww8
Javanotes ww8
 
Java notes
Java notesJava notes
Java notes
 
1.introduction to java
1.introduction to java1.introduction to java
1.introduction to java
 
Java chapter 1
Java   chapter 1Java   chapter 1
Java chapter 1
 
Java1
Java1Java1
Java1
 
Java
Java Java
Java
 
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
 
Java introduction
Java introductionJava introduction
Java introduction
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)
 
Top 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdfTop 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdf
 
College Project - Java Disassembler - Description
College Project - Java Disassembler - DescriptionCollege Project - Java Disassembler - Description
College Project - Java Disassembler - Description
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
 
Presentación rs232 java
Presentación rs232 javaPresentación rs232 java
Presentación rs232 java
 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
 
java slides
java slidesjava slides
java slides
 
Java unit 1
Java unit 1Java unit 1
Java unit 1
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 

Mehr von Arati Gadgil (16)

Java adapter
Java adapterJava adapter
Java adapter
 
Java swing
Java swingJava swing
Java swing
 
Java applet
Java appletJava applet
Java applet
 
Java layoutmanager
Java layoutmanagerJava layoutmanager
Java layoutmanager
 
Java awt
Java awtJava awt
Java awt
 
Java stream
Java streamJava stream
Java stream
 
Java thread
Java threadJava thread
Java thread
 
Java networking
Java networkingJava networking
Java networking
 
Java jdbc
Java jdbcJava jdbc
Java jdbc
 
Java package
Java packageJava package
Java package
 
Java interface
Java interfaceJava interface
Java interface
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Java eventhandling
Java eventhandlingJava eventhandling
Java eventhandling
 
Java exception
Java exception Java exception
Java exception
 
Java collection
Java collectionJava collection
Java collection
 
Java class
Java classJava class
Java class
 

Kürzlich hochgeladen

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 

Kürzlich hochgeladen (20)

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 

Java basic

  • 2. 2 Java Java was developed in the early 90s by Sun Microsystems Java is a high-level language. There are many features of java. They are also known as java buzzwords. Simple Java omits many rarely used, poorly understood, confusing features of C++. Say : No Pointer! No dynamic delete.
  • 3. 3 Object Oriented Object –oriented design is a technology that focuses design on the data (object) and on the interfaces to it. Everything is an object, everything will become a class in Java. Every java program, in top- level view, is classes. Robust The single biggest difference between Java and C/C++ is that Java has “a inner safe pointer-model”, therefore it eliminates the possibility of overwriting memory and corrupting data, so programmers feel very safe in coding.
  • 4. 4 Distributed Basically, Java is for Net-Work application, for WEB project. Java can open and access “objects” across the Net via URLs (Uniform Resource Locator) eg. “http//:gamut.neiu.edu/~ylei/home.html”, with the same ease as when accessing a local file system Platform Independent Java code can be run on multiple platforms e.g. Windows, Linux, Sun Solaris,Mac/OS etc. Java code is compiled by the compiler and converted into bytecode.This bytecode is a platform independent code because it can be run on multiple platforms i.e. Write Once and Run Anywhere(WORA).
  • 5. 5 Secured Java is secured because: No explicit pointer,Programs run inside virtual machine sandbox also, •Classloader- adds security by separating the package for the classes of the local file system from those that are imported from network sources. •Bytecode Verifier- checks the code fragments for illegal code that can violate access right to objects. •Security Manager- determines what resources a class can access such as reading and writing to the local disk
  • 6. 6 Architecture-neutral The compiler generates an architecture-neutral object file format. The compile code can run on many processors ,given the presence of the runtime system. The java compiler does this by generting bytecode instruction which have nothing to do with a particular computer architecture. Portable We may carry the java bytecode to any platform. High-performance Java is faster than traditional interpretation since byte code is "close" to native code still somewhat slower than a compiled language (e.g., C++)
  • 7. 7 Multi-threaded A thread is like a separate program, executing concurrently. We can write Java programs that deal with many tasks at once by defining multiple threads. The main advantage of multi- threading is that it shares the same memory. Threads are important for multi-media, Web applications etc. Dynamic In number of ways, java is more dynamic language than C or C++.It was designed to adapt to an evolving environment. Libraries can freely add new methods and instance variables without any effect on their clients. In java finding out runtime type information is straightforward.
  • 8. 8 Java Virtual Machine The .class files generated by the compiler are not executable binaries, Java combines compilation and interpretation. Instead, they contain “byte-codes” to be executed by the Java Virtual Machine. This approach provides platform independence, and greater security. The JVM performs following main tasks: •Loads code •Verifies code •Executes code •Provides runtime environment
  • 9. 9 JRE JRE is an acronym for Java Runtime Environment. It is used to provide runtime environment.It is the implementation of JVM. It physically exists.It contains set of libraries + other files that JVM uses at runtime. JDK JDK is an acronym for Java Development Kit. It physically exists. It contains JRE + development tools
  • 10. 10 JVM Java Virtual Machine (JVM) is an abstract computing machine. Java Runtime Environment (JRE) is an implementation of the JVM. Java Development Kit (JDK) contains JRE along with various development tools like Java libraries, Java source compilers, Java debuggers, bundling and deployment tools.
  • 12. 12 JIT JIT refers to execution engine in few of JVM implementations, one that is faster but requires more memory, is a just-in-time compiler. In this scheme, the bytecodes of a method are compiled to native machine code the first time the method is invoked. JIT refers to execution engine in few of JVM implementations, one that is faster but requires more memory,is a just-in-time compiler. In this scheme, the bytecodes of a method are compiled to native machine code the first time the method is invoked.
  • 13. 13 Java Bytecode Java bytecode is the instruction set of the Java virtual machine. Eachbytecode is composed by one, or in some cases two, bytes that represent the instruction (opcode), along with zero or more bytes for passing parameters.. Bytecode is nothing but the intermediate representation of Java source code which is produced by the Java compiler by compiling that source code. This byte code is an machine independent code.It is not an completely a compiled code but it is an intermediate code somewhere in the middle which is later interpreted and executed by JVM
  • 14. 14 HotSpot, released as the "Java HotSpot Performance Engine"is a Java virtual machine for desktops and servers, maintained and distributed by Oracle Corporation. It features techniques such as just- in-time compilation and adaptive optimization designed to improve performance. Sun intended to write a new just-in-time (JIT) compiler for the newly developed virtual machine.This new compiler would give rise to the name "HotSpot", which derives from the fact that, as the software runs Java bytecode, it continually analyzes the program's performance for "hot spots" which are frequently or repeatedly executed. These are then targeted for optimization, leading to high- performance execution with a minimum of overhead for less performance-critical code Java HotSpot
  • 15. 15 Sun's JRE features two virtual machines, one called Client and the other Server. The Client version is tuned for quick loading. It makes use of interpretation. The Server version loads more slowly, putting more effort into producing highly optimized JI compilations, that yield higher performance. Both VMs compile only often-run methods, using a configurable invocation-count threshold to decide which methods to compile. The HotSpot Java virtual machine is written in C++. As stated on the HotSpot web page, the source contains approximately 250,000 lines of code. Hotspot provides: •A class loader •A bytecode interpreter •Client and Server virtual machines, optimized for their respective uses •Several garbage collectors •A set of supporting runtime libraries
  • 16. 16 The main() method public static void main(String args[]) { ... } public--- the interpreter can call it. static ----It is a static method belonging to the class. void -----It does not return a value. String----It always has an array of String objects as its formal parameter. the array contains any arguments passed to the program on the command line.The source file’s name must match the class name which main method is in.
  • 17. 17 Source File Declaration Rules There can be only one public class per source code file. Comments can appear at the beginning or end of any line in the source code file; they are independent of any of the positioning rules discussed here. If there is a public class in a file, the name of the file must match the name of the public class. For example, a class declared as public class Dog { }must be in a source code file named Dog.java. If the class is part of a package, the package statement must be the first line in the source code file, before any import statements that may be present.
  • 18. 18 If there are import statements, they must go between the package statement (if there is one) and the class declaration. If there isn't a package statement, then the import statement(s) must be the first line(s) in the source code file. If there are no package or import statements, the class declaration must be the first line in the source code file. import and package statements apply to all classes within a source code file. In other words, there's no way to declare multiple classes in a file and have them in different packages, or use different imports. A file can have more than one nonpublic class. Files with no public classes can have a name that does not match any of the classes in the file
  • 19. 19 Comments /* 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 */
  • 20. 20 Primitive types •int 4 bytes •short 2 bytes •long 8 bytes •byte 1 byte •float 4 bytes •double 8 bytes •char Unicode encoding (2 bytes) •boolean {true,false} Behaviors is exactly as in C++
  • 21. 21 • Constants 37 integer 37.2 float 42F float 0754 integer (octal) 0xfe integer (hexadecimal) • Comparison operators == equal != not equal < less than > greater than <= less than or equal >= greater than or equal
  • 22. 22 Variable declaration type variable-name; Meaning: variable <variable-name> will be a variable of type <type> Where type can be: int //integer double //real number Example: int a, b, c; double x; int sum;
  • 23. 23 String is an Object Constant strings as in C, does not exist  The function call show(“Hello”) creates a String object, containing “Hello”, and passes reference to it to show.  The String object is a constant. It can’t be changed using a reference to it.
  • 24. 24 Writing to user (output) System.out.println(variable-name); prints the value of variable <variable-name> to the user System.out.println(“any message “); prints the message within quotes to the user System.out.println(“hello” + “world” + a + “plus“ + b); assuming the value of a is 3 and of b is 7, it prints helloworld3plus7 Note: System.out.println() always prints on a new line.
  • 25. 25 Example /* This program illustrates the System.out.println command. */ public class Hello { public static void main (String args[]) { System.out.println(“This is my first Java program!”); System.out.print(“I like Java.”); System.out.print(“I think Java is cool.”); } // end of main } // end of class
  • 26. 26 Example /* Printing ages. */ public class MyFirstJavaProgram { public static void main (String args[]) { int myAge, myFriendAge; /* declare two integer variables */ myAge = 20; myFriendAge = myAge + 1; //one year older System.out.println(“Hello, I am “ +myAge + “years old, and my friend is “ + myFriendAge + “ years old”); System.out.println(“Goodbye”); } // end of main } // end of class
  • 27. 27 Flow control if/else do/while for switch If(x==4) { // act1 } else { // act2 } int i=5; do { // act1 i--; } while(i!=0); int j; for(int i=0;i<=9;i++) { j+=i; } char c=IN.getChar(); switch(c) { case ‘a’: case ‘b’: // act1 break; default: // act2 }
  • 28. 28 Big Numbers If the precision of the basic integer and floating-point types is not sufficient, you can turn to a couple of handy classes in the java.math package, called BigInteger and BigDecimal. These are classes for manipulating numbers with an arbitrarily long sequence of digits. The BigInteger class implements arbitrary precision integer arithmetic, and BigDecimal does the same for floating-point numbers. Use the static valueOf method to turn an ordinary number into a big number: BigInteger a = BigInteger.valueOf(100); BigInteger c = a.add(b); // c = a + b BigInteger d = c.multiply(b.add(BigInteger.valueOf(2))); // d = c * (b + 2)
  • 29. 29 Array •Array is an object • Array size is fixed A[] arr; // nothing yet … arr = new A[4]; // only array of pointers for(int i=0 ; i < arr.length ; i++) arr[i] = new Animal();
  • 30. 30 Arrays - Multidimensional • In C++ Animal arr[2][2] Is: • In Java What is the type of the object here ? A[][] arr= new A[2][2]