0% found this document useful (0 votes)
7 views

Introduction To Java

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Introduction To Java

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Introduction to Java

• Java: A versatile programming language


• Developed by Sun Microsystems, now owned by
Oracle Corporation
• Released in 1995, widely used across the globe
Key Concepts in Java
• Platform Independence
• Object-Oriented Programming (OOP)
• Syntax and Structure
• Basic Data Types and Control Flow
• Packages and Libraries
• IDEs and Development Tools
Platform Independence

• Java programs compiled into bytecode


• Bytecode runs on any device with Java Virtual Machine
(JVM)
• "Write once, run anywhere" principle
Object-Oriented Programming (OOP)
• Java is an object-oriented language
• Objects represent real-world entities with attributes and
behaviors
• Understanding OOP principles essential for Java
development
Syntax and Structure

• Java syntax similar to C-style languages (e.g., C++, C#)


• Programs organized into classes, blueprints for objects
• Classes contain fields (variables) and methods (functions)
• .Java & Javac
Basic Data Types and Control Flow
• Java supports primitive data types (int, double, boolean, char)
• Complex data types include arrays and strings
• Control flow statements (if-else, loops, switch-case) for
program flow control
Packages and Libraries

• Java provides Java Standard Edition (Java SE)


libraries
• Libraries offer pre-built functionality for common
tasks
• Developers can use third-party libraries and
frameworks to extend capabilities
IDEs and Development Tools

• Integrated Development Environments (IDEs) like IntelliJ


IDEA, Eclipse, NetBeans
• IDEs offer tools for writing, debugging, testing Java code
• Features include code autocompletion, syntax highlighting,
project management.
How java changed the internet
• Internet was young, websites were simple creatures, composed mainly of static
pages.
• Java : interactivity and dynamism.
• Java enabled the creation of applets—tiny programs that could run within web
browsers.
• websites were no longer static; they became dynamic and engaging playgrounds.
• Instead of mere text and images, you find interactive games, animated graphics,
and real-time data updates.
• With Java's server-side technologies like Servlets and JavaServer Pages (JSP),
developers could create powerful web applications capable of handling vast
amounts of data and serving millions of users simultaneously.
• As time went on, Java continued to evolve, adapting to the ever-changing
landscape of the Internet.
Basic Java Program

public class Demo //class definition


{
public static void main(String args[])
{
void display()
{
System.out.println(“Good afternoon");
}
//statements
}
}
Program Read and Print an Integer value in Java
// Java program to take an integer as input and print it
import java.io.*;
import java.util.Scanner;
// Driver Class
class Example {
// main function
public static void main(String[] args)
{
// Declare the variables
int num;
// Input the integer
System.out.println("Enter the integer: ");
// Create Scanner object
Scanner s = new Scanner(System.in);
// Read the next integer from the screen
num = s.nextInt();
// Display the integer
System.out.println("Entered integer is: " + num);
}
}
Ways to read input from console in Java
// Java program to demonstrate BufferedReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
public static void main(String[] args) throws IOException
{
// Enter data using BufferReader
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// Reading data using readLine
String name = reader.readLine();
// Printing the read line
System.out.println(name);
}
// Java program to demonstrate working of System.console()
// Note that this program does not work on IDEs as
// System.console() may require console
public class Sample {
public static void main(String[] args)
{
// Using Console to input data from user
String name = System.console().readLine();

System.out.println("You entered string " + name);


}
}
// Program to check for command line arguments
class Hello {
public static void main(String[] args)
{
// check if length of args array is greater than 0
if (args.length > 0) {
System.out.println(“The command line arguments are:");
// iterating the args array and printing the command line arguments
for (String val : args)
System.out.println(val);
}
else
System.out.println("No command line "+ "arguments fouund.");
}
• Ways to read input from console in Java - GeeksforGeeks

You might also like