Java Tutotrial for [NLP-AI] 2

Slides:



Advertisements
Similar presentations
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
Advertisements

CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Java Syntax Part I Comments Identifiers Primitive Data Types Assignment.
©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
CMT Programming Software Applications
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
A simple program: Area of a circle Problem statement: Given the radius of a circle, display its area Algorithm: 4. Display area To store values, we need.
CSci 142 Data and Expressions. 2  Topics  Strings  Primitive data types  Using variables and constants  Expressions and operator precedence  Data.
Methods: a first introduction Two ways to make tea: 1: boil water; put teabag into cup;... etc : tell your younger brother: makeTea(1 milk, 0 sugar);
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
“Introduction to Programming With Java”
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Welcome to the Lecture Series on “Introduction to Programming With Java”
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
The string data type String. String (in general) A string is a sequence of characters enclosed between the double quotes "..." Example: Each character.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
CIS 260: App Dev I. 2 Programs and Programming n Program  A sequence of steps designed to accomplish a task n Program design  A detailed _____ for implementing.
The basics of the array data structure. Storing information Computer programs (and humans) cannot operate without information. Example: The array data.
CIS 260: App Dev I. 2 Programs and Programming n Program  A sequence of steps designed to accomplish a task n Program design  A detailed _____ for implementing.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Output in Java Hello World!. Structure of a Java Program  All Java files in ICS3U1 have the following structure: class HelloWorld { }  Notice the open.
1 Variables. 2 Receipt example What's bad about the following code? public class Receipt { public static void main(String[] args) { // Calculate total.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
1 BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA AND DEFINITE LOOPS.
ECE 122 Feb. 1, Introduction to Eclipse Java Statements Declaration Assignment Method calls.
VARIABLES Programmes work by manipulating data placed in memory. The data can be numbers, text, objects, pointers to other memory areas, and more besides.
CSC141 Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture - 6.
Chapter 2 topics Concept # on Java Subset Required for AP Exam print and println10. Testing of output is restricted to System.out.print and System.out.println.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
Chapter 2 Input, Variables and Data Types. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are.
Copyright 2010 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Agenda Comments Identifiers Keywords Syntax and Symentics Indentation Variables Datatype Operator.
CS 106 Introduction to Computer Science I 09 / 10 / 2007 Instructor: Michael Eckmann.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
CS 106 Introduction to Computer Science I 01 / 24 / 2007 Instructor: Michael Eckmann.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
UFCFY5-30-1Multimedia Studio Coding for Interactive Media Fundamental Concepts.
Copyright 2010 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Primitive data types Lecture 03. Review of Last Lecture Write a program that prints the multiplication table of 5. class MultiplicationTable { public.
Chapter # 2 Part 2 Programs And data
Chapter 2 Variables.
Console Output, Variables, Literals, and Introduction to Type
Introduction to Computer Science / Procedural – 67130
Documentation Need to have documentation in all programs
Multiple variables can be created in one declaration
Lecture Note Set 1 Thursday 12-May-05
Java Programming: From Problem Analysis to Program Design, 4e
OUTPUT STATEMENTS GC 201.
Chapter 2.
Chapter 2: Basic Elements of Java
Building Java Programs
Chapter # 2 Part 2 Programs And data
Lecture Notes - Week 2 Lecture-1. Lecture Notes - Week 2 Lecture-1.
Building Java Programs
Building Java Programs
Building Java Programs
Chapter 2 Variables.
Just Enough Java 17-May-19.
Lexical Elements & Operators
Building Java Programs
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Building Java Programs
Presentation transcript:

Java Tutotrial for [NLP-AI] 2 ashishfa@cse.iitb.ac.in 4 December 2018

Last Assignment ? Print the details in tabular format - use tabs \t asgn1 asgn2 Last Assignment ? Print the details in tabular format - use tabs \t System.out.println("\"Can we print '\\' with System.out.println() statement?\"" ); 4 December 2018 Java Tutorial series part 2

Java Tutorial series part 2 Storing data In Java, Data can be stored as Numbers 2, 6.67, 0.009 Characters ‘c’, ‘p’, ‘?’, ‘2’ Strings “data”, “Hindi language”, “$99”, “www.rediff.com” 4 December 2018 Java Tutorial series part 2

Java Tutorial series part 2 Program int1 int2 // this program will declare and print a number class int2 { public static void main(String[] arguments) int weight = 68; System.out.println("your weight is " + weight); } //end of program 4 December 2018 Java Tutorial series part 2

Comments(double slash) Not executed For documentation Can be placed on any line Anything written after // is not executed E.g. // this is a comment Used to explain/describe what is done in the program Good practice 4 December 2018 Java Tutorial series part 2

Java Tutorial series part 2 Types of numbers float1 int Whole numbers like 0, 575, -345 etc. double Numbers with decimal point like 12.453, 3.432, 0.0000002 4 December 2018 Java Tutorial series part 2

Java Tutorial series part 2 Variable declaration Before using any name, it must be declared (with its type i.e int or double). Needed only once in one program Generally, done initially Syntax datatype name; double total; // stores the total value int index; int a,b , c, sum, interest; 4 December 2018 Java Tutorial series part 2

Java Tutorial series part 2 Assignment int3 int5 int a; //declaration – needed once a = 10 ; // assignment … declared above int a = 10; // assignment and declaration together 10 = a ; // not possible – compilation error Left hand side is always a variable for assignment Storage area a 10 4 December 2018 Java Tutorial series part 2

Java Tutorial series part 2 Assignment… int4 int a , b ; a = 4; b = 7; a = b; b = a; a = 5; // a =? b = ? // a = 4 b = ? // a = 4 b = 7 // a = 7 b = 7 // a = 7 b = 7 // a = 5 b = 7 4 December 2018 Java Tutorial series part 2

Java Tutorial series part 2 Character data char1 char2 Characters ‘a’, ‘A’, ‘c’ , ‘?’ , ‘3’ , ‘ ’ (last is the single space) Enclosed in single quotes Character variable declaration char ch; Character assignment ch = ‘k’; 4 December 2018 Java Tutorial series part 2

Java Tutorial series part 2 string1 string2 string3 String data Strings are sequence of characters enclosed in double quotes Declaration String name; String address; String line; Assignment name = “ram”; line = “this is a line with spaces”; name = “a”; // single character can be stored name = “”; // empty string The sequence of characters enclosed in double quotes, printed in println() are also strings. E.g. System.out.println( “Welcome ! “ ); 4 December 2018 Java Tutorial series part 2

Java Tutorial series part 2 Practice problem Try to print these two figures on the screen using println and least number of strings ******* ***** *** * ********** * * 4 December 2018 Java Tutorial series part 2

Java Tutorial series part 2 Thank you 4 December 2018 Java Tutorial series part 2