Professional Documents
Culture Documents
Introduction to JAVA
Distributed
Interpreted
– The program are compiled into Java Virtual Machine (JVM) code called bytecode
– Each bytecode instruction is translated into machine code at the time of execu:on
What is Java?
Robust
– Java is simple
– no pointers/stack concerns
– Exception handling
https://youtu.be/ZIuKKFPIKjQ
Difference Between JDK JRE JVM
Bytecode
● The same bytecodes can be executed on any platform containing a compatible JVM
● The JVM is invoked by the java command
– java Welcome
● It searches the class Welcome in the current directory and executes the main
method of class Welcome.
● It issues an error if it cannot find the class Welcome or if class Welcome does not
contain a method called main with proper signature
Phase 1: Creating a Program
● Any text editor or Java IDE (Integrated Development Environment) can be used to
develop Java programs
● Java source-code file names must end with the .java extension
● Some popular Java IDEs are
– NetBeans
– Eclipse
– JCreator
– IntelliJ
Phase 2: Compiling a Java Program
● javac Welcome.java
Static:
Void: ItItis
Public: Itisaisakeyword
keyword
an and
which
Access used
is to
when
modifier, specify
associated
which that a method
with
specifies a method,
from doesn’t
where makes
return
and whoanything.
it a can
classaccess
related
As main()
method.
the method
Thedoesn’t
method. main()return
Making method
the
String[]It args:
main: is theItname
storesofJava
Javacommand
main method.line arguments
It is the identifier
and is an that
array
theofJVMtype
looks
java.lang.String
for as the starting
class. Here,
point of
the
is
anything,
static method
main() soits
that
return
JVM type
can makes
public invoke
is void.it
itAswithout
soon asinstantiating
globally the main()Itmethod
the class.terminates,
This also
sosaves
the java
the program
unnecessary
terminates
wastagetoo.of Hence,
the java
name of program.
the String It’s
array
notisaargs but it is available.
keyword. not fixed and is user
made can public
use any that
nameJVMin can
placeinvoke
of it. it from outside
memory
it
thedoesn’t
classwhich
make
as it iswould
any
notsense
havetobeen
present return
used
in thefrom
by main()
the object
current method
class. declared
as JVM
only
can’t
for calling
do anything
the main()
with the
method
return
byvalue
the JVM.
of it.
Data-types
Integers*: byte (1 byte), short(2 bytes), int (4 bytes), long(8 bytes)