[Go to site: main page, start]

0% found this document useful (0 votes)
4 views15 pages

Java Programming Basics

Java is a widely-used programming language developed by James Gosling in 1995, known for its platform independence and strong community support. It is secure, easy to learn, and suitable for various applications, including mobile, web, and desktop software. The Java compilation process involves converting source code into bytecode, which is executed by the Java Virtual Machine (JVM).
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views15 pages

Java Programming Basics

Java is a widely-used programming language developed by James Gosling in 1995, known for its platform independence and strong community support. It is secure, easy to learn, and suitable for various applications, including mobile, web, and desktop software. The Java compilation process involves converting source code into bytecode, which is executed by the Java Virtual Machine (JVM).
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

What is Java?

The Java programming language is...


• Java is a popular programming language, created in 1995.
• Java was developed by James Gosling at Sun Microsystems in
the early 1990s, with its first public release in 1995, and later
acquired by Oracle Corporation, which now maintains it. It is
used for:
• Mobile applications (specially Android apps)
• Desktop applications, Web applications
• Web servers and application servers
• Games, Database connection
• And much, much more!
Why use java?
• Java works on different platforms (Windows, Mac, Linux,
Raspberry Pi, etc.) called platform independence
• It is one of the most popular programming language in the
world
• It has a large demand in the current job market
• It is easy to learn and simple to use
• It is open-source and free
Why use java?
• It is secure, fast and powerful
• Java uses JVM. Bytecode is verified before execution. No
direct memory access (no pointers). Prevents malicious
code.
• Developed to be platform-independent: 'Write Once, Run
Anywhere'.
Why use java?
• It has a huge community support (tens of millions of
developers)
• Java is an object oriented language which gives a clear
structure to programs and allows code to be reused,
lowering development costs
• As Java is close to C++ and C#, it makes it easy for
programmers to switch to Java or vice versa
Java Compilation and Execution Process
Java Source Code (.java)

Java Compiler

Bytecode (.class)

Java Virtual Machine (JVM)

Program Output
Java Compilation and Execution Process
• Java source code (.java) is compiled by javac.
• Compiler produces bytecode (.class).
• JVM interprets or compiles bytecode to run the program.
Java Virtual Machine (JVM)
• JVM is an engine that runs Java bytecode.
• Converts bytecode into machine-specific instructions.
• Allows Java programs to run on different operating
systems.
Key Features of Java
Object-Oriented
Platform Independent
Secure and Robust
Multithreaded and Portable
Sample Coding
public class HelloWorld {
public static void main(String[] args) {
[Link]("Hello, World!");
}
}
Java Syntax
• Java programs are case-sensitive.
• Every program must have a class.
• The main method is the program entry point.
• [Link]() – prints without a new line.
• [Link]() – prints with a new line.
Java Syntax
• Case Sensitivity: Java is case-sensitive, meaning that uppercase
and lowercase letters are treated as distinct. For example, Hello
and hello are considered different identifiers.
• Class Declaration: A Java program typically starts with the definition
of a class. The public keyword indicates that the class is accessible
from outside the package. The class keyword is used to declare a
class.
Java Syntax
• Main Method: The main method is the entry point for Java
programs. It has a specific signature:
• Comments in Java are specified using // for single-line comments
or /* */ for multi-line comments.
• Variables: Variables are declared with a data type and an identifier.
• Data Types: Java has various data types, including primitive types
(e.g., int, double, boolean) and reference types (e.g., String,
custom classes).
Java Syntax
• Control Flow Statements: Java supports standard control flow
statements like if, else, for, while, and switch.
• Object Instantiation: Creating objects involves using the new
keyword.
• Methods: Methods are declared within classes and can take
parameters and return values.
• Packages and Imports: Java code is organized into packages, and
classes within packages are imported as needed.
Java Syntax
• Exception Handling: Exceptions are handled using try, catch, finally,
and throw blocks.

You might also like