Java Programming Language PDF

Summary

This document provides an overview of the Java programming language, its history, milestones, and various applications including mobile apps, big data, scientific appliances, gaming and cloud computing. Detailed syntax, structure and data types are also covered.

Full Transcript

JAVA Mobile application – most andoid app are written or use Java as language - high-level, class-based, object-oriented programming language. Big...

JAVA Mobile application – most andoid app are written or use Java as language - high-level, class-based, object-oriented programming language. Big data technologies - like Apache Hadoop, Apache - general-purpose programming language Spark. - "write once, run anywhere" (WORA). Scientific appliances - data processing, mathematical - by James Gosling, Mike Sheridan, and Patrick calculations, and simulations. Naughton at Sun Microsystems in 1991 - initially called "Oak" Gaming - used in developing 2D and 3D games, as well as mobile games. MILESTONE OF JAVA Cloud computing - like AWS, Google Cloud, and Azure 1991 - was initiated by James Gosling and the Green for developing scalable and distributed systems. Team at Sun Microsystems (originally designed for interactive television) 1995 – Officially launched Java 1.0 JAVA SYNTAX AND STRUCTURE 1997 – JDK 1.1 released 1999 – released of J2SE 1.2 , J2EE and J2ME public: The method is accessible from outside the class. 2004 – released of Java 5.0 (JS2E 1.5) static: Allows the method to run without creating an instance of the class. 2006 – released under General public license, making it free and open-source software void: The method does not return any value. 2014 - Java 8 features like lambda expressions, Stream String[] args: Command-line arguments passed to the API program. 2017 – announced that java would switch to a new Variable – Act as container to store data release cadence, new version every 6 months - int Present Java – used in wed development, mobile - double applicaion and large-scale enterpricec systems. - string Used for: Initialization – Assigning initial value to a variale - mobile app (andriods) - int age= - desktop app - string name = - web app - web servers and app servers 2 primary data types - games - Primative data types - database connection - Reference data types REAL WORLD APPLICATION Primative data Types Web application - used for building server-side - Btye - 1 byte small numbers applications. - Short – 2 bytes slightly larger no. - Frameworks like Spring, Hibernate, and Struts - Int: - 4 bytes integer type - Long – 8 bytes larger integer value Enterprise application - specifically designed for - Float - 4 bytes single-precision floating point building distributed, multi-tiered, transactional - Double – 8 bytes decimal values applications - Char - 2bytes sinle unicode character - Boolean – 1 bit true or flase Reference Data Type Conditional statement - Include classes, interfaces, arrays, string, and If statement – if the condition is true , simplest decision custom classes making stat. - They store references to object rather than the else if ladder – first true condition’s block gets executed, object itself the rest are skipped. Local variables – Accessible only within that method Looping statement Instance Variable (Fields) – declared within the class While loop – executes as long as condition is true but outside any method Do-while loop – block of code executed because it is Class variables (static fields) - declared within the static check after the block is executed keyword and shared across all instances of all class For loop – used when you know how many times you Java operators – perform operations on variables want to loop - Arithmetic operators o Addition(+) , Subtraction(-), Multiplication(*), Division(/), Modulus CODE EXAMPLE: (%) - Assignment operators import java.util.Scanner; o Use to assign values to variables (=) public class Main { - Compound assignment operators public static void main(String[] args) { o Operation with assignment Scanner scanner = new Scanner (System.in); ▪ +=, -=, *+, /= System.out.print("Enter your age: "); - Comparison operators int age = scanner.nextInt(); o To compare, Boolean result (true or false) if (age >= 18) { ▪ Equal to (==), Not equal to (!=), System.out.println("You are eligible to vote."); - Logical operators }else { o Combining multiple condition, Boolean System.out.println("You are not eligible to result vote."); ▪ AND && - Returns true if both } stat is true } } ▪ OR || - True if one condition is true ▪ NOT ! – inverts the Boolean value - Increment or Decrement o To increase and decrease ▪ Increment ++ ▪ Decrement – Conditional Statement – flow of execution to be controlled within a program - Making decisions, repeating tasks or branching paths Java control statement - Decision-making statement - Looping (iteration) statement

Use Quizgecko on...
Browser
Browser