A Short Introduction to JAVA

Slides:



Advertisements
Similar presentations
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Advertisements

1 Java Basics. 2 Compiling A “compiler” is a program that translates from one language to another Typically from easy-to-read to fast-to-run e.g. from.
Introduction to Java Programming, 4E
Some basic I/O.
Hello, world! Dissect HelloWorld.java Compile it Run it.
Introduction to Java Programming Language Junji Zhi University of Toronto 1.
INTRODUCTION TO JAVA PROGRAMMING Chapter 1. What is Computer Programming?
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
CMSC 341 Introduction to Java Based on tutorial by Rebecca Hasti at
CSC3170 Introduction to Database Systems
DAT602 Database Application Development Lecture 5 JAVA Review.
Chapter 1 Introduction to Java 10/8/2015 Lecture 1 1.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Introduction to Computer Systems and the Java Programming Language.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
POS 406 Java Technology And Beginning Java Code
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Introduction to Java Programming with Forte Y. Daniel Liang.
CSE 131 Computer Science 1 Module 1: (basics of Java)
CS591x A very brief introduction to Java. Java Developed by Sun Microsystems was intended a language for embedded applications became a general purpose.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
CIT 590 Intro to Programming First lecture on Java.
JAVA BASICS Prepared by The Smartpath Information Systems
Chapter 2: Java Fundamentals
Object Oriented Programming Lecture 3. Introduction  In discussing Java, some items need to be clarified  The Java programming language  The Java virtual.
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
Group 4 Java Compiler Group Members: Atul Singh(Y6127) Manish Agrawal(Y6241) Mayank Sachan(Y6253) Sudeept Sinha(Y6483)
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Fall 2015CISC124 - Prof. McLeod1 CISC124 Have you filled out the lab section survey? (As of last night 54 left to fill out the survey.) TA names have been.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Applied Computing Technology Laboratory QuickStart Java Learning to Program in Java Dr. Tom Way October 21, 2005.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
CS101: Introduction to Computer Science Slides adapted from Sedgewick and Wayne Copyright © Your First Java.
1 Basic Java Constructs and Data Types – Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
CSc 201 Introduction to Java George Wells Room 007, Hamilton Building
By Mr. Muhammad Pervez Akhtar
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Aside: Running Supplied *.java Programs Just double clicking on a *.java file may not be too useful! 1.In Eclipse, create a project for this program or.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Features of JAVA PLATFORM INDEPENDENT LANGUAGE JAVA RUNTIME ENVIRONMENT (JRE) JAVA VIRTUAL MACHINE (JVM) JAVA APP BYTE CODE JAVA RUNTIME ENVIRONMENT.
Introduction to Java Programming, 4E Y. Daniel Liang.
Introduction to Java Programming by Laurie Murphy Revised 09/08/2016.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Information and Computer Sciences University of Hawaii, Manoa
Introduction to Java Import Scanner class to use in our program
Chapter No. : 1 Introduction to Java.
Internet and Java Foundations, Programming and Practice
Programming Language Concepts (CIS 635)
An Introduction to Java – Part I
Introduction to Java.
Introduction to Java Programming
An Introduction to Java – Part I, language basics
Units with – James tedder
Units with – James tedder
Java Programming Review 1
Introduction to Java Brief history of Java Sample Java Program
Java Basics Data Types in Java.
Introduction to java Part I By Shenglan Zhang.
JAVA. Java is a high-level programming language originally developed by Sun Microsystems and released in Java runs on a variety of platforms, such.
Presentation transcript:

A Short Introduction to JAVA Kazi Masudul Alam

JAVA Object-oriented programming language developed by Sun Microsystems. Currently owned by ORACLE (ORACLE bought Sun Microsystems) Designed to be small, simple, and portable across platforms and operating systems Source, binary work in Windows, Linux, Mac OS Android OS and apps are motivated from JAVA like language. In 1991, James Gosling and Sun Microsystems began designing a language for home appliances (toasters, TVs, etc.). challenging, because home appliances are controlled by many different chips (processors) Programs were translated first into an intermediate language common to all appliance processors. Then the intermediate language was translated into the machine language for a particular appliance’s processor. Appliance manufacturers weren’t impressed. In 1994, Gosling realized that his language would be ideal for a Web browser that could run programs over the Internet. Sun produced the browser known today as HotJava.

Different Editions JAVA Standard Edition (J2SE) Enterprise Edition (J2EE) Micro Edition (J2ME) J2SE is for desktop applications. We will be using this version of JAVA J2ME is for embedded systems ranging from Mobile Phone, Watch, Set top box, Microwave, Fridge etc. J2EE is for enterprise applications with heavily distributed nature. Very important to know the stacks and techniques used. Highly demanded in the job market.

JAVA Architecture

JAVA Application Development A compiler translates a program from a high-level language to a low-level language the computer can run. The Java compiler does not translate a Java program into assembly language or machine language for a particular computer. Instead, it translates a Java program into byte-code. Byte-code is the machine language for a hypothetical computer (or interpreter) called the Java Virtual Machine. A byte-code program is easy to translate into machine language for any particular computer. A program called an interpreter translates each byte-code instruction, executing the resulting machine-language instructions on the particular computer before translating the next byte-code instruction. After compiling a Java program into byte-code, that byte-code can be used on any computer with a byte-code interpreter and without a need to recompile. Byte-code can be sent over the Internet and used anywhere in the world.

JAVA Editors DrJava Nebeans IDE Eclipse Others www.drjava.org (A light weight IDE) Nebeans IDE https://netbeans.org/downloads Eclipse https://eclipse.org/downloads/ Others Blue, JCreator, EJE Eclipse is the most used editor. It can work with many other programming language. Also, many other research works develop their plugins to design the systems using Eclipse

DrJAVA

J2SE Development Java SE Development Kit (8/7/6) required to develop and compile the code Java SE Runtime Environment (8/7/6) required to execute the program Download here http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

First Java program public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); }

Saving and Running Save it as HelloWorld.java. Again, make sure that the filename is the same case as the class name. Compile and run it: javac HelloWorld.java Compiling will generate HelloWorld.class file java HelloWorld java HelloWorld.class Your computer should display Hello, world!

Errors An error in a program is called a bug. Eliminating errors is called debugging. three kinds or errors syntax errors runtime errors logic errors Syntax error grammatical mistakes in a program the grammatical rules for writing a program are very strict The compiler catches syntax errors and prints an error message. example: using a period where a program expects a comma Runtime error errors that are detected when your program is running, but not during compilation When the computer detects an error, it terminates the program an prints an error message. example: attempting to divide by 0 Logic error errors that are not detected during compilation or while running, but which cause the program to produce incorrect results

Sum of 2 numbers class FirstProgram

Samples – Data Type

Samples – Control Statement

Samples – Loop

Variable Types Local variables Instance variables Static variables Constant

Modifier Types Access Modifier Visible to the package, the default. No modifiers are needed. Visible to the class only (private). Visible to the world (public). Visible to the package and all subclasses (protected).

Modifier Types Non-Access Modifier The static modifier for creating class methods and variables The final modifier for finalizing the implementations of classes, methods, and variables. The abstract modifier for creating abstract classes and methods. The synchronized and volatile modifiers, which are used for threads

Arithmetic Operators Output:

Relational Operators

Logical Operators

JAVA Numbers xxxValue() Converts the value of this Number object to the xxx data type and returned it valueOf() Returns an Integer object holding the value of the specified primitive. toString() Returns a String object representing the value of specified int or Integer. parseInt() This method is used to get the primitive data type of a certain String sqrt() Returns the square root of the argument. random() Returns a random number.

JAVA Character and String isLetter() Determines whether the specified char value is a letter isDigit() Determines whether the specified char value is a digit. isUpperCase() Determines whether the specified char value is uppercase isLowerCase() Determines whether the specified char value is lowercase

JAVA Character and String compareTo(String anotherString) Compares two strings lexicographically. endsWith(String suffix) Tests if this string ends with the specified suffix byte[] getBytes(String charsetName) Encodes this String into a sequence of bytes using the named charset int indexOf(int ch) Returns the index within this string of the first occurrence of the specified character. int length() Returns the length of this string. boolean matches(String regex) Tells whether or not this string matches the given regular expression.

JAVA Array dataType[] arrayRefVar =new dataType[arraySize]; double[] myList =new double[10];

JAVA Methods Passing parameter by value

JAVA Files and I/O

Input / Output

Exception Handling

JAVA Multi Threading

Other Features Package Interface Encapsulation Abstraction Polymorphism Over riding Over loading Inheritance

LAB Fill the required logic in the given code so that the output of the program matches. Only use control statements for/while/do-while if/else if/else break/continue Dot not use 2D Array! Write the out patterns in a file. Then read the file and print it in screen.

Lab Outputs Desired Output Sample Code

References Thanking. Prof. Ivan Stojmenovic http://www.learnjavaonline.org/ http://www.tutorialspoint.com/java/java_tutorial.pdf